473,394 Members | 1,709 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,394 software developers and data experts.

check existing connections to a .MDB file

ed
Hi, how do i check if other applications is already connected to an access database (.mdb file)? Let's say I have an application that opens an mdb file, for example - test.mdb. Then I opened another instance of the same application and it will also connect to the same mdb file, in this case - test.mdb. What i want is for the application to detect/check/filter that another application is connected to the .mdb file, thus preventing the second instance of the application from connecting to the same file

Thanks in advance :)
Nov 20 '05 #1
4 1698
CT
Open the connection in exclusive mode (Mode=Share Exclusive in the
connection string) and the second connection will fail, so you catch it in a
Try-Catch block.

--
Carsten Thomsen
Enterprise Development with VS .NET, UML, and MSF
http://www.apress.com/book/bookDisplay.html?bID=105
"ed" <an*******@discussions.microsoft.com> wrote in message
news:BA**********************************@microsof t.com...
Hi, how do i check if other applications is already connected to an access database (.mdb file)? Let's say I have an application that opens an mdb
file, for example - test.mdb. Then I opened another instance of the same
application and it will also connect to the same mdb file, in this case -
test.mdb. What i want is for the application to detect/check/filter that
another application is connected to the .mdb file, thus preventing the
second instance of the application from connecting to the same file.
Thanks in advance :)

Nov 20 '05 #2
Hi Ed,

As a minor addition to CT.

Normally it is good sence to close connections everytime you have filled a
dataset.
For a access database it is better to open it at the start and at the end of
the program.

Cor
Nov 20 '05 #3
CT
Hi Ct

I tried your suggestion (Mode=Share Exclusive) but it didn't work. I was still able to open the MDB file successfully from the two applications.

I'm just working on a connections string made by someone else and it looks like this

'start strin
Public Const gstrCon1 As String = "Provider=Microsoft.Jet.OLEDB.4.0;"
& "Password="""";User ID=Admin;Data Source=c:\test.mdb
Public Const gstrCon2 As String = ";"
& "Mode=Share Exclusive;Extended Properties="""";Jet OLEDB:System database="""";"
& "Jet OLEDB:Registry Path="""";Jet OLEDB:Database Password="""";Jet OLEDB:Engine Type=5;"
& "Jet OLEDB:Database Locking Mode=0;Jet OLEDB:Global Partial Bulk Ops=2;"
& "Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="""";"
& "Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;"
& "Jet OLEDB:Compact Without Replica Repair=False;"
& "Jet OLEDB:SFP=False

conNew = New OleDb.OleDbConnection(gstrCon1 & gstrCon2
conNew.Open(

'end strin

Given that connection string, do you see anything strange? The initial value of Mode before i changed it to "Share Exclusive" is "Share Deny None". I have yet to research on these properties but you guys might have a quick answer so that would really be great

Thanks again :

Nov 20 '05 #4
ed
oops sorry, made a mistake on the display name.
Nov 20 '05 #5

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

Similar topics

3
by: Mudge | last post by:
Hi, My hosting provider only allows me to use 50 connections to my MySQL database that my Web site will use. I don't know what this 50 connections means exactly. Does this mean that only 50...
3
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called...
1
by: jbi130 | last post by:
I have a 3 tier client/server application where the client connection to the server which then uses PostgreSQL. I'd like to extend the client to have direct access to PostgreSQL but do not want to...
19
by: wetherbean | last post by:
Hi group..I am writing a playlist management protocol where I have a file that holds all the playlists and a file that holds all the songs....before a playlist is created I need to check to see if...
1
by: jazzandlatin | last post by:
Hi everybody Could somebody tell me how it is possible to check that any connection opened in a page be closed when the page has been published ? My problem is that SQL server looks saturated...
5
by: Nikolay Petrov | last post by:
1. Can I use SSL for my web services? 2. How can implement some kind of security to my web services? My idea is to implement some kind of licensing or user/password authentication for an web...
6
by: test2000 | last post by:
Hello I'm trying to write a javascript that checks if a server/host is available. To be more precice. I would like to check if the browser can read an XML file from a server. If not the script...
6
by: Hemant Shah | last post by:
Folks, One of our clients is performing an audit, and the auditor(s) asked following question, and I am not sure how to answer it: 28. Is there a control that prevents the corruption of...
4
by: billiejoex | last post by:
Hi, I'm writing a small asyncore-based server application serving a lot of clients. When I have to handle more than 1021 client simoultaneously the 'binded' socket object raises an error: ...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
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...

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.