I have an Access database with a table and 2 columns.
ybOrderNums webOrderNums
10000 20000
And I have a chunk of code that reads one of the numbers (depending on which type of job) increments the number, and replaces it with the new, incremented number.
However, I am getting some customers with duplicate numbers. Here is my code:
I am not sure how to set this to pessimistic connections, so only one person can read the data at a time. Or should I do a stored procedure?
ybOrderNums webOrderNums
10000 20000
And I have a chunk of code that reads one of the numbers (depending on which type of job) increments the number, and replaces it with the new, incremented number.
However, I am getting some customers with duplicate numbers. Here is my code:
Code:
Dim strNewNumI, srcColumn, strNewNum As String
Dim objTable As New DataTable("NewOrders")
Dim objReader As OleDb.OleDbDataReader
Dim objConn As New OleDbConnection(dbAccess)
Dim cmdNewNum As New OleDbCommand("SELECT * FROM tblNewOrderNum", objConn)
Select Case oType
Case ordType.WebOrder
srcColumn = "wOrders"
Case ordType.YBOrder
srcColumn = "yOrders"
End Select
objConn.Open()
objReader = cmdNewNum.ExecuteReader
Do While objReader.Read
strNewNum = objReader(srcColumn)
Loop
objReader.Close()
strNewNumI = strNewNum + 1
cmdNewNum.CommandText = "UPDATE tblNewOrderNum SET " & srcColumn & " = '" & strNewNumI & "' "
cmdNewNum.ExecuteNonQuery()
objConn.Close()
Return strNewNumI
I am not sure how to set this to pessimistic connections, so only one person can read the data at a time. Or should I do a stored procedure?