I
id10t error
I have the code below. I am running an Rf application and trying to
get multiple scanners to work at the same time. I put in a mutex
before this class is called. The problem is the first time the second
scan that goes through the following code gets an error. I even tried
to put in a 10 second wait to mutex to give the first scan plenty of
time to clear the class. Is there a way to clear the connection string
that I am not doing?
Public Function Firstrecord(ByVal userid As String, ByVal
programid As String)
Dim test As String = 0
'This will be used to store the date in number format
Dim todaynumber As String
' If works delete
'Dim b As String = DateTime.Now.ToString("yyyy/MM/dd
hh:mm:ss")
'Gets current time
Dim currenttime As String = DateTime.Now.ToString("HHmmss")
'sets number scan to 000 so for reports we know this is a
starting record
Dim numberscan As String = "000"
'This calls the get today number function and gets todays date
in number format
todaynumber = gettodaynumberfunc()
'Gets the store number from the Web Config file
Dim storenumber As String =
ConfigurationManager.AppSettings.Get("storenumber")
'This is used to setup the connection string to write the
record
Dim TPSupdate As New Data.Odbc.OdbcConnection()
TPSupdate.ConnectionString =
ConfigurationManager.AppSettings.Get("DSNEMPMST")
TPSupdate.ConnectionString =
ConfigurationManager.AppSettings.Get("EMPMSTconnection")
'Opens the connection to get data from TPS file
TPSupdate.Open()
'Declares an object of OdbcCommand Object to execute the
select statement
Dim insertCmd As New Data.Odbc.OdbcCommand()
'Sets the propertirs of the command object
insertCmd.Connection = TPSupdate
insertCmd.CommandTimeout = 1000
'This will setup the record to be inserted into the table
insertCmd.CommandText = "Insert into RFPRD
(Numberscan,storenum,programid,usernumber,datescanned,timescanned)
Values ('" & numberscan & "','" & storenumber & "','" & programid &
"'," & userid & "," & todaynumber & "," & currenttime & ")"
'This is the command that will insert the record into
RFPRD.tps
insertCmd.ExecuteNonQuery()
TPSupdate.Close()
Return test
End Function
get multiple scanners to work at the same time. I put in a mutex
before this class is called. The problem is the first time the second
scan that goes through the following code gets an error. I even tried
to put in a 10 second wait to mutex to give the first scan plenty of
time to clear the class. Is there a way to clear the connection string
that I am not doing?
Public Function Firstrecord(ByVal userid As String, ByVal
programid As String)
Dim test As String = 0
'This will be used to store the date in number format
Dim todaynumber As String
' If works delete
'Dim b As String = DateTime.Now.ToString("yyyy/MM/dd
hh:mm:ss")
'Gets current time
Dim currenttime As String = DateTime.Now.ToString("HHmmss")
'sets number scan to 000 so for reports we know this is a
starting record
Dim numberscan As String = "000"
'This calls the get today number function and gets todays date
in number format
todaynumber = gettodaynumberfunc()
'Gets the store number from the Web Config file
Dim storenumber As String =
ConfigurationManager.AppSettings.Get("storenumber")
'This is used to setup the connection string to write the
record
Dim TPSupdate As New Data.Odbc.OdbcConnection()
TPSupdate.ConnectionString =
ConfigurationManager.AppSettings.Get("DSNEMPMST")
TPSupdate.ConnectionString =
ConfigurationManager.AppSettings.Get("EMPMSTconnection")
'Opens the connection to get data from TPS file
TPSupdate.Open()
'Declares an object of OdbcCommand Object to execute the
select statement
Dim insertCmd As New Data.Odbc.OdbcCommand()
'Sets the propertirs of the command object
insertCmd.Connection = TPSupdate
insertCmd.CommandTimeout = 1000
'This will setup the record to be inserted into the table
insertCmd.CommandText = "Insert into RFPRD
(Numberscan,storenum,programid,usernumber,datescanned,timescanned)
Values ('" & numberscan & "','" & storenumber & "','" & programid &
"'," & userid & "," & todaynumber & "," & currenttime & ")"
'This is the command that will insert the record into
RFPRD.tps
insertCmd.ExecuteNonQuery()
TPSupdate.Close()
Return test
End Function