If two people connecting, or utilizing the resource, at the same time crashes the thing, then don't let two people connect at the same time. Use the lock keyword, or a custom semaphore/mutex, to ensure that only one person can access the non-threadsafe resource at a time.
∞ Andy Badera ∞ This email is: [ ] bloggable [x] ask first [ ] private ∞ Google me: http://www.google.com/search?q=(andrew+badera)+OR+(andy+badera) On Mon, Aug 31, 2009 at 9:36 AM, id10t error<[email protected]> wrote: > > Hello, > > I am making a scanner application. It is an asp.net program. I am > having a problem when the users are using two scanners at one and they > try to write to the TPS file at the same time. Here is my code. Is > there anything i am doing wrong. If two people scan at the same time > the scanners will freeze up. > > 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() > insertCmd.Dispose() > TPSupdate.Close() > TPSupdate.Dispose() >
