Error when using Network share Access File

A

alan

I've use VB.NET+Access to write build a simple POS application. For
example i got two computer, comp A and comp B. Which comp A share a
Access db file through the network. When open a new bill, the
application will get the latest bill Id from the Access db file and
then update the bill Id=bill Id+1. Right now comp A have already get
the bill Id and update the bill Id=bill iD+1. 2 sec later, comp B also
try to get the bill Id. There is no problem when it get the bill Id,
but there is an error when it try to update the bill Id. Why?

The code that I get the bill Id and update the bill Id is as follow:

'**********************
'Get the Bill Id
'*********************
Dim transMain As OleDbTransaction
cmd = New OleDbCommand
cmd.CommandText = "select next_order_id from [shop]"
Try
cnn = New OleDbConnection(conStr)
cmd.Connection = cnn
cmd.CommandType = CommandType.Text
cnn.Open()

transMain = cnn.BeginTransaction()
cmd.Transaction = transMain
custOrderid = cmd.ExecuteScalar()
transMain.Commit()
cnn.Close()
Catch exp As Exception
transMain.Rollback()
MsgBox("1")
MsgBox(exp.Message)
Catch err As OleDbException
transMain.Rollback()
MsgBox("2")
MsgBox(err.Message)
End Try


'******************
Update the Bill Id
'******************
Dim transMain As OleDbTransaction
Try

cmd.CommandText = "Update shop set next_order_id=" & custOrderid +
1 & " "

cnn = New OleDbConnection(conStr)

cmd.Connection = cnn
cmd.CommandType = CommandType.Text

MsgBox(cnn.State)

cnn.Open()
MsgBox(cnn.State)
transMain = cnn.BeginTransaction()
cmd.Transaction = transMain
cmd.ExecuteScalar()
transMain.Commit()

cnn.Close()
cnn.Dispose()

Catch exp As Exception
MsgBox("5")
MsgBox(exp.Message)
transMain.Rollback()
Catch err As OleDbException
MsgBox("6")
MsgBox(err.Message)
transMain.Rollback()

End Try
 
C

Cor

Hi Alan,

In this message is almost no VB.language code with exception of the show of
the messageboxes and the try, catch and end try.

I think you have a better change to get an answer for this in the
public.dotnet.framework.adonet newsgroup.

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top