470,590 Members | 2,521 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,590 developers. It's quick & easy.

Error when using Network share Access File

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
Nov 20 '05 #1
1 2056
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

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

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Dermot O'Loughlin | last post: by
reply views Thread by =?Utf-8?B?TG93bGFuZGVy?= | last post: by
8 posts views Thread by msnews.microsoft.com | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.