Update Sql Db After All Records Have Been Printed
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"
rs.update
'rs.delete
end if
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"
rs.update
'rs.delete
end if
0
-
Permanently deleted user
★ BarTender Hero ★
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 Cancelled0 -
What's the difference between OnPrintEnd and OnPrintJobEnd? Are they interchangeable?
0 -
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?
Thanks,
Valerie0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
3 Kommentare