473,473 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2191
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Dermot O'Loughlin | last post by:
Can anyone help me with this? I get the following error when using the odbc adapter wizard in VS.Net 2003: --------------------------- Wizard Form --------------------------- An unexpected...
1
by: bjbounce2002 | last post by:
Hello, I am using forms with command buttons to close form or run action queries. The error messages such as "Null value in required field" or "duplicate value in primary key" are suppressed....
7
by: Charts | last post by:
I login as administrator of the machine. However running the following code get access denied exception for file inside the directory. The source code: DirectoryInfo target = new...
4
by: mattsthompson | last post by:
Im writing a DLL that extends IHttpHandler to intercept requests for a certain file extension and deliver watermarked images. I'm using LeadTools' .NET framework for the image manipulation and it...
1
by: alan | last post by:
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...
0
by: Charlie | last post by:
Hi: I get a TreeNode binding error when using Data property of XmlDataSource control. When I switch to TextFile property and point to xml file on hard drive, problem goes anyway. I'm...
0
by: =?Utf-8?B?TG93bGFuZGVy?= | last post by:
Hello, I've built a web application that uses client script callbacks. It is used on a large network with a large variety of user OSes and IE versions. It was tested on IE 6 on different setups...
8
by: msnews.microsoft.com | last post by:
Our IT team relocated our application servers yesterday. They had to take one machine out of the cluster because it would prompt users for credentials if accessed using the IP address, which I...
7
by: svsenthilkumar | last post by:
Hai, I got an javascript error when using ajax in mozilla browser, anyone help me why the error is coming, meaning for this error and how can i rectify this error. Error: " nsresult:...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.