473,387 Members | 1,588 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Access locking and transactions

Hi all,

I'm using the following setup:
VB.Net (.NET framework 1.1)
Access2000
SharpDevelop 1.1 for development (it is very similar to Visual Studio
..NET)

using ODBCConnection, ODBCCommand, etc.

The ODBC.NET and Access2000 combination supports transactions. So I've
put it into the application.

I have to print a report from Access.
I have the following code:
(wherever attention is needed, I have marked it as "NOTE")
(dbo,glob,errmgr are instances of classes I have made for handling the
database, global values and errors, respectively)

Private Sub BtnPrintAllClick(sender As System.Object, e As
System.EventArgs)
Try
Dim amcobj As New CAMC(glob, dbo, errmgr)
Dim printobj As New CPrint(glob, dbo, errmgr)
Dim i, j As Integer, dbrow As DataRow
dbo.Begin() 'ID7 <--- NOTE: This issues a
ODBCConnection.BeginTransaction()
printobj.ClearTable()
For i = 0 To Results.Rows.Count - 1
'amcobj.Fetch(Results.Rows(i)("AMCNo"), 0)
dbrow = Results.Rows(i)
printobj.AMCNo = dbrow("AMCNo")
printobj.CustID = dbrow("CustID")
printobj.VisitCount = dbrow("VisitCount")
printobj.AMCStart = dbrow("AMCStart")
printobj.AMCEnd = dbrow("AMCEnd")
printobj.Amount = dbrow("Amount")
printobj.Name = dbrow("Name")
printobj.Area = dbrow("Area")
printobj.Tel = dbrow("Tel")
printobj.Add()
Next
dbo.Commit() 'ID7 <---NOTE: this issues a ODBCTransaction.Commit()
dbo.CloseConn() 'ID7 <---NOTE: this issues a ODBCConnection.Close()
Dim acobj As New Access.Application
acobj.OpenCurrentDatabase(glob.DBPath, False) <---NOTE: This fails
strangely giving error [1]
acobj.Visible = True
acobj.DoCmd.OpenReport("PrintAMCs", Access.AcView.acViewPreview,
Nothing, Nothing )
'acobj.Quit(Access.AcQuitOption.acQuitSaveNone)
'acobj = Nothing
dbo.OpenConn() 'ID7
Catch ex As System.Exception
dbo.Rollback() 'ID7
errmgr.LogMsg(Me.GetType().FullName, ex)
errmgr.ShowError(errmgr.EInternal,MsgBoxStyle.Crit ical)
End Try

End Sub

[1] the error is ->
System.Runtime.InteropServices.COMException (0x800A1EBA): Microsoft
Access can't open the database because it is missing, or opened
exclusively by another user.
at Access.ApplicationClass.OpenCurrentDatabase(String filepath,
Boolean Exclusive)
at NSAMC.MainForm.BtnPrintAllClick(Object sender, EventArgs e) in
C:\data\projects\SharpDevelop\AMC\MainForm.vb:line 979

The interesting part is that when I run the .exe from inside the IDE
(SharpDevelop) it does not
give an error - an Access window pops up and neatly shows me the
report. However, if I simply copy the entire set of files (exe, pdb,
manifest, mdb, dll) in the Debug folder into an independent location
then I get this error. I do not think it is to do with SharpDevelop
because the executables output into the Debug/Release deirectory are
pretty much standard - .exe, .dll,.pdb, .manifest etc.

Any clues?
TIA,
JS

May 17 '06 #1
2 3010
On 17 May 2006 01:16:45 -0700, "Joseph S." <js****@rediffmail.com> wrote:

¤ Hi all,
¤
¤ I'm using the following setup:
¤ VB.Net (.NET framework 1.1)
¤ Access2000
¤ SharpDevelop 1.1 for development (it is very similar to Visual Studio
¤ .NET)
¤
¤ using ODBCConnection, ODBCCommand, etc.
¤
¤ The ODBC.NET and Access2000 combination supports transactions. So I've
¤ put it into the application.
¤
¤ I have to print a report from Access.
¤ I have the following code:
¤ (wherever attention is needed, I have marked it as "NOTE")
¤ (dbo,glob,errmgr are instances of classes I have made for handling the
¤ database, global values and errors, respectively)
¤
¤ Private Sub BtnPrintAllClick(sender As System.Object, e As
¤ System.EventArgs)
¤ Try
¤ Dim amcobj As New CAMC(glob, dbo, errmgr)
¤ Dim printobj As New CPrint(glob, dbo, errmgr)
¤ Dim i, j As Integer, dbrow As DataRow
¤ dbo.Begin() 'ID7 <--- NOTE: This issues a
¤ ODBCConnection.BeginTransaction()
¤ printobj.ClearTable()
¤ For i = 0 To Results.Rows.Count - 1
¤ 'amcobj.Fetch(Results.Rows(i)("AMCNo"), 0)
¤ dbrow = Results.Rows(i)
¤ printobj.AMCNo = dbrow("AMCNo")
¤ printobj.CustID = dbrow("CustID")
¤ printobj.VisitCount = dbrow("VisitCount")
¤ printobj.AMCStart = dbrow("AMCStart")
¤ printobj.AMCEnd = dbrow("AMCEnd")
¤ printobj.Amount = dbrow("Amount")
¤ printobj.Name = dbrow("Name")
¤ printobj.Area = dbrow("Area")
¤ printobj.Tel = dbrow("Tel")
¤ printobj.Add()
¤ Next
¤ dbo.Commit() 'ID7 <---NOTE: this issues a ODBCTransaction.Commit()
¤ dbo.CloseConn() 'ID7 <---NOTE: this issues a ODBCConnection.Close()
¤ Dim acobj As New Access.Application
¤ acobj.OpenCurrentDatabase(glob.DBPath, False) <---NOTE: This fails
¤ strangely giving error [1]
¤ acobj.Visible = True
¤ acobj.DoCmd.OpenReport("PrintAMCs", Access.AcView.acViewPreview,
¤ Nothing, Nothing )
¤ 'acobj.Quit(Access.AcQuitOption.acQuitSaveNone)
¤ 'acobj = Nothing
¤ dbo.OpenConn() 'ID7
¤ Catch ex As System.Exception
¤ dbo.Rollback() 'ID7
¤ errmgr.LogMsg(Me.GetType().FullName, ex)
¤ errmgr.ShowError(errmgr.EInternal,MsgBoxStyle.Crit ical)
¤ End Try
¤
¤ End Sub
¤
¤ [1] the error is ->
¤ System.Runtime.InteropServices.COMException (0x800A1EBA): Microsoft
¤ Access can't open the database because it is missing, or opened
¤ exclusively by another user.
¤ at Access.ApplicationClass.OpenCurrentDatabase(String filepath,
¤ Boolean Exclusive)
¤ at NSAMC.MainForm.BtnPrintAllClick(Object sender, EventArgs e) in
¤ C:\data\projects\SharpDevelop\AMC\MainForm.vb:line 979
¤
¤ The interesting part is that when I run the .exe from inside the IDE
¤ (SharpDevelop) it does not
¤ give an error - an Access window pops up and neatly shows me the
¤ report. However, if I simply copy the entire set of files (exe, pdb,
¤ manifest, mdb, dll) in the Debug folder into an independent location
¤ then I get this error. I do not think it is to do with SharpDevelop
¤ because the executables output into the Debug/Release deirectory are
¤ pretty much standard - .exe, .dll,.pdb, .manifest etc.
¤

First, you should not use the Microsoft Access ODBC driver. The Microsoft Jet OLEDB provider is more
stable and offers much better support with respect to database features.

Second, in your OpenCurrentDatabase statement if you try to open the database for exclusive access
when the database is already open, the open will fail.
Paul
~~~~
Microsoft MVP (Visual Basic)
May 18 '06 #2
Hi,
thanks for the suggestions.
Paul Clement wrote:
First, you should not use the Microsoft Access ODBC driver. The Microsoft Jet OLEDB provider is more
stable and offers much better support with respect to database features.

Second, in your OpenCurrentDatabase statement if you try to open the database for exclusive access
when the database is already open, the open will fail.

As it turns out, the error was due to wrong data - the wrong database
path was being picked from a text file - it was fixed by simply
changing the data in the text file.

Second, I'll start out with Jet OLEDB.

Thanks,
JS

May 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Alban Hertroys | last post by:
Good day, I have a number of threads doing inserts in a table, after which I want to do a select. This means that it will occur that the row that I want to select is locked (by the DB). In these...
1
by: David McGeorge | last post by:
Dear Gurus, A Client has the following problems/requests for their Production databases, what is your professional/practical advises to tackle and resolve these issues: 1)Number of...
0
by: brijeshmathew | last post by:
Hi I use Visual Basic 6, Service Pack 6, Microsoft ActiveX Data Objects 2.8 Library(msado15.dll) and access 2000 database using JET 4 OLE. I have an application that adds records simultaneously...
2
by: Adnan | last post by:
Hey Ppl, I'm developing an Online Auction Site using ASP.net and am experiencing a problem with Transactions in ADO.Net. When beginTrasaction() function is invoked from a specific connection,...
3
by: RayPower | last post by:
I'm having a system using Access 2000 as both front-end (queries, forms, reports & temp tables for reports) & back-end (data) with back-end running on the server. The application runs on the...
49
by: Mell via AccessMonster.com | last post by:
I created databases on Access 2003 and I want to deploy them to users. My code was also done using 2003. If they have Ms Access 2000 or higher, will they be able to use these dbs with all code,...
0
by: shakahshakah | last post by:
Just started investigating InnoDB after having used MyISAM tables in the 4.0.12 version, almost immediately ran into a locking issue with INSERTs, DELETEs, and transactions. Given the following...
8
by: Allan Ebdrup | last post by:
I've implemented transactions in my dotNet 2.0 project using System.Transactions and TransactionScope. --- TransactionOptions options = new TransactionOptions(); options.IsolationLevel =...
14
by: Luvin lunch | last post by:
Hi All, People keep saying things like "Access is a nightmare" or "Access is hell" but the only people I hear this from are peopel who aren't that experienced in using Access. The most I can...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.