Update Database Simultaneously
I'm working on a template which using 2 PC
Condition:-
This two PC is sharing a running number with connect to the server database
When this 2 pc run the template simultaneously, it allow to save the running number.
However i have no idea where i put the script
I try to put on OnPostPrompt an OnPrintEnd event
OnPostPrompt:- only get 1 update instead of 2
OnPrintEnd:- didn't update at all
[code]
dim objConn
dim strConn
dim rs
dim num
dim strUpdateExcel
'Set the connection string for the SQL file.
strConn="Provider=SQLOLEDB.1;Data Source=weserver01;Initial Catalog=MSTGOLF;user id ='sa';password='123'"
'save the last printed serial number back to Sql server.
Set objConn = CreateObject("ADODB.Connection")
objConn.Open strConn
Set myCommand = CreateObject("ADODB.Command" )
Set myCommand.ActiveConnection = objConn
'recompute the running number for next print job.
sNextRunNo = Field("tbPrint.RunningNo") + Format.NumberSerializedLabels
objConn.BeginTrans
myCommand.CommandText= "Update tbPrint Set RunningNo = '"& sNextRunNo &"' Where CompanyID ='"& ID &"'"
myCommand.Execute
objConn.CommitTrans
objConn.Close
[/code]
Condition:-
This two PC is sharing a running number with connect to the server database
When this 2 pc run the template simultaneously, it allow to save the running number.
However i have no idea where i put the script
I try to put on OnPostPrompt an OnPrintEnd event
OnPostPrompt:- only get 1 update instead of 2
OnPrintEnd:- didn't update at all
[code]
dim objConn
dim strConn
dim rs
dim num
dim strUpdateExcel
'Set the connection string for the SQL file.
strConn="Provider=SQLOLEDB.1;Data Source=weserver01;Initial Catalog=MSTGOLF;user id ='sa';password='123'"
'save the last printed serial number back to Sql server.
Set objConn = CreateObject("ADODB.Connection")
objConn.Open strConn
Set myCommand = CreateObject("ADODB.Command" )
Set myCommand.ActiveConnection = objConn
'recompute the running number for next print job.
sNextRunNo = Field("tbPrint.RunningNo") + Format.NumberSerializedLabels
objConn.BeginTrans
myCommand.CommandText= "Update tbPrint Set RunningNo = '"& sNextRunNo &"' Where CompanyID ='"& ID &"'"
myCommand.Execute
objConn.CommitTrans
objConn.Close
[/code]
0
-
Shotaro Ito
★ BarTender Hero ★
Hi Kai
Try Datasource number of serialized labels. Give that datasource to share name.
(Print dialog, Number of serialized copy (Serial numbers) option to Datasouce, go to datasource tab and set datasource name)
In OnPostPrompt event, add current serial number + serial copies to get expected last number, then update.
Excuse me about very rough explanation - hope that helps.0
Please sign in to leave a comment.
Comments
1 comment