PC Review


Reply
Thread Tools Rate Thread

check existing connections to a .MDB file

 
 
=?Utf-8?B?ZWQ=?=
Guest
Posts: n/a
 
      24th May 2004
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
 
Reply With Quote
 
 
 
 
CT
Guest
Posts: n/a
 
      24th May 2004
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" <(E-Mail Removed)> wrote in message
news:BAB1DF7F-9A6A-412D-ACE7-(E-Mail Removed)...
> 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



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      24th May 2004
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


 
Reply With Quote
 
=?Utf-8?B?Q1Q=?=
Guest
Posts: n/a
 
      25th May 2004
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 OLEDBatabase Password="""";Jet OLEDB:Engine Type=5;"
& "Jet OLEDBatabase 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 OLEDBon'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 :

 
Reply With Quote
 
=?Utf-8?B?ZWQ=?=
Guest
Posts: n/a
 
      25th May 2004
oops sorry, made a mistake on the display name.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
existing connections HeatherAnn Microsoft Excel Worksheet Functions 4 31st Oct 2009 04:08 PM
XP Pro, no new tcp/ip connections, existing connection work David Ball Windows XP Networking 0 6th Oct 2005 09:56 PM
Non-existing Network Connections Kathy@nospam.com Windows XP General 0 1st Nov 2004 05:41 PM
New connections not allowed into existing IPSec security associati =?Utf-8?B?Um9ja3k=?= Microsoft Windows 2000 Networking 1 6th Oct 2004 06:47 PM
check if there is an existing connection on an MDB file =?Utf-8?B?ZWQ=?= Microsoft VB .NET 2 25th May 2004 12:26 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:24 AM.