Connect To Access


New member
Feb 24, 2005
Programming Experience
i hav a problem conencting to my Database from Vb.Net. im totally new to .Net.the code is as follows

Dim DBConn As New OleDb.OleDbConnection
Dim strSql As String


strSql = "Provider = Microsoft.Jet.OleDB.4.0;Data Source =" + _


DBConn =
New OleDb.OleDbConnection(strSql)


i could not connect to the database.

the error message is

"Work group information file is missing or is exclusively used by another user"

can any body explain the reasons 4 this error?

one more thing...
is ther anyhing like "Debug.print" in VB.Net ?

thanks in advance


The best way to do it is to let .NET do it for you. Go to your tool box and under the "Data" tab drag and drop an "oledbdataadapter" onto your form. After doing this a data connection wizard will open up and walk you through you connection. Make sure you select the correct provider in the wizard. Often its set to SQL Server and not jet. Just click on the provider tab in the wizard and set it to jet then procede to the next tab set up your connection. After you test the connection ond it passes go to the properties window for the oledbconnection it created and copy the connection string and paste it into a notepad (or somthing else). Here you can look at the string and play around with it. If you want to hand code it at least you'll have a very good (and most important) working connection string to play with.

The error you getting can be happen for several reasons. The most common one is you have the access database open already on your machine or sobody else has and its setup for exclusive use. Another is that your using a password on a system that dosent have workgroup security turned on.

The minimun connection string used should be somthing like this
Provider="Microsoft.Jet.OLEDB.4.0";Data Source="D:\MyDB.mdb";Password=;User ID=Admin

the one .NET will create looks like this

Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=; _
Jet OLEDB:Database Locking Mode=1;Data Source="D:\MyDB.mdb"; _
Jet OLEDB:Engine Type=5;Provider="Microsoft.Jet.OLEDB.4.0"; _
Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False; _
Extended Properties=;Mode=Share Deny None;Jet OLEDB:Encrypt Database=False; _ 
Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False; _ 
Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1

You may get better (faster) responses to you questions in the VB.NET general forums. The CF forum is for .NET compact framework(CF) which is mainly for PDA's (Handheld devices) and this forum dosent generate as much traffic as the general forums do.

I hope some of this has helped. Good luck

Last edited by a moderator:

Latest posts