Connect To Access

babu123

New member
Joined
Feb 24, 2005
Messages
1
Programming Experience
1-3
hi
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

Try

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

"D:\MyDB.mdb;UserID=Admin;Password=MyPasswd"

DBConn =
New OleDb.OleDbConnection(strSql)

DBConn.Open()

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

baburaj
 

dashley

Well-known member
Joined
May 27, 2005
Messages
59
Location
Tennessee
Programming Experience
10+
Babu123,

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
VB.NET:
Provider="Microsoft.Jet.OLEDB.4.0";Data Source="D:\MyDB.mdb";Password=;User ID=Admin
the one .NET will create looks like this

VB.NET:
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 vb.net 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


Dan
 
Last edited by a moderator:

lei_tx

New member
Joined
Sep 26, 2006
Messages
1
Programming Experience
Beginner
Thanks for your code

Hi,
Take a look at the attachment and see how it works in deeds ... Cheers ;)
Thank you Kulrom, that's really helpfull, thank you very much!:D :D :D
 

srdva59

Active member
Joined
Feb 21, 2009
Messages
28
Programming Experience
Beginner
hi,
there is any way to do this but in a pocket pc?
thanks for your help :)
 
Top Bottom