Update Sql Db After All Records Have Been Printed Follow

Legacy Poster

hi everyone,
i have a c# app that sends a command line to bartender to print labels

is there a way to configure the labels to update the corresponding record in the database, but only if the print job has been completed ?

i have tried putting a vb script in OnPrintEnd event but the DB updates automatically
whether the label was printed or not

thanks in advance!

here is my vb script:

'Define the object names.
dim objConn
dim rs
dim id

'Define the database connection parameter constants.
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001

'Get the id of the current printed record (another barcode with record id)
id = Format.Objects("Bar Code 4").Value

'Connect to the sql DB.
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=SQLOLEDB;Data Source=myDataSource;Initial Catalog=myDB;Persist Security Info=True;user id=myid;password=mypass;"

'Create a record set of one record which is the current record being printed.
Set rs = CreateObject("ADODB.Recordset")
rs.open "SELECT * FROM [tbl_Bartender] where ID= '" & id & "'", objConn, adOpenStatic, adLockOptimistic, adCmdText

if not rs.eof then
rs.Fields("Comment") = "YES"
end if


Ian Einman
Comment actions Permalink

Yes, try this:

1. Open BarTender Document Options
2. Go to VB Scripting tab
3. Open Functions and Subs, and add a line "Dim Cancelled"
4. Open OnPrintJobStart, add a line "Cancelled = 0"
5. Open OnPrintJobCancel, add a line "Cancelled = 1"
6. In OnPrintJobEnd, put your code in an If statement that checks Cancelled
Legacy Poster
Comment actions Permalink

What's the difference between OnPrintEnd and OnPrintJobEnd?  Are they interchangeable?

Legacy Poster
Comment actions Permalink

How do I debug my code.  I have the code above integrated into my script and when it executes there are no errors.  There is also no update.  Is there a way I can figure out where the problem is?


If there was a problem with permissions on the database would I get an error?



Please sign in to leave a comment.