Inserting Data To Sql Database Follow
I am new to BarTender and have had some success with this, but still have some issues.
I would appreciate any help on this.
Here is what I am doing. I have created a task in Commander to listen for two pieces of data and once the connection closes, it sends this data to BarTender. The first piece of data is an order number and the second is the quantity. They are separated by a comma. I have set up in Bartender the two database fields (Field1 and Field2).
I am taking this order number and quantity using that as parameters in a stored procedure to insert a record into a SQL database. This same stored procedure returns a unique number that will be printed on the label. No other information is needed on the label but this unique number.
I have written the stored procedure, and know it works. I have also written vbscript and put it in the barcode object under the OnNewRecord Event Control and that works too.
Here is the problem. It seems that the vbscript is run multiple times even though I sent one record (order number and quantity). I know this because in the db table, I see 13 added records. One of those records is correct, but the other 12 have the "sample" data (12345678) as the order number.
I am not sure why this is happening.
Thanks for any help folks can offer.
Here is a copy of the vbscript. NOTE: Server name and database name have been changed to protect the innocent. :)
Set objConnection = CreateObject("ADODB.Connection")
Set cmd = CreateObject("ADODB.Command")
.CommandType = 4
.ActiveConnection = objConnection
.CommandText = "sp_InsertOrderRecord"
.Parameters.Append .CreateParameter ("@OrderNb",200,1,10,Field("Pallet.Field 1"))
.Parameters.Append .CreateParameter ("@Qty",3,1,4,Field("Pallet.Field 2") )
.Parameters.Append .CreateParameter ("@UniqueNb",200,2,32)
retval = cmd.parameters("@UniqueNb").value
Set cmd = Nothing
Set objConnection = Nothing
Value = retval
Michael Toupin (mtoupin
Please sign in to leave a comment.