Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP!! Database connection!!!

Status
Not open for further replies.

ii128

Programmer
May 18, 2001
129
US
Any one can tell me what is wrong with my connection???

Dim adoConn As ADODB.Connection

Set adoConn = New ADODB.Connection

adoConn.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ= \\TEST\My Filder\Example.mdb" 'App.Path & "\Examples.mdb"

adoConn.Open
 
Have you tried a different connection string? If you build one using the Adodc1, it looks like this:

Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDBPath.mdb;Persist Security Info=False

If ur using Access 97 or later you should be able to use Jet3.51 or Jet4.0. May be worth a try...

~Mike
Any man willing to sacrifice liberty for security deserves neither liberty nor security.

-Ben Franklin
 
I would like to connect the Access database from Visual basic. The database is located in network and the network computer doesn't map a drive. I have the computer's name and folder name. What should I do to connect that database from Visual basic???
 
ConnectionString=Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\Win98\C\abc\Colleges.mdb

Works also for Access 2 Peter Meachem
peter@accuflight.com
 
Like this

adoConn.ConnectionString = Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\NetworkServer\NetworkComp\SharedDir\example.mdb;Persist Security Info=False;


Hope this helps.

jason
 
IF I would like to assign the password in the MS Access 2000 database then what will be the connection string.
 

Thanks for every body & this is very good question, I’ll use this question to request a simple example using (Adodc1) but running in network Environment. Moreover, this well help us to solve our problem

Let’s assume The following.
Server Name : server1
Database Name: sample1.mdb (MS access 2000).
User Name : scott
Password : tiger


Grasp All, Lose All
 
Hi check this:

---------------
Private cnn As New ADODB.Connection
Private strcnn As String
Private rs As New ADODB.Recordset
Private sDataBaseName As String

sDataBaseName="c:\MyDB"
cnn.ConnectionString = "ODBC;DBQ=" & sDataBaseName & ";UID=;PWD=;Driver={Microsoft Access Driver (*.mdb)}"
cnn.open

Set rs = New ADODB.Recordset
strcnn = "SELECT * FROM NewTable"
rs.open strcnn, cnn, adOpenDynamic, adLockOptimistic

For more detail check my FAQ:faq222-1422(Create Acess Database, Tables and Fields through VB)

Thanks Murali Bala
 
Well, This code running in a local machine, What do you think if we locte datebase on network.Let's say on server_1,on C drive.

Is this code correct? --> sDataBaseName="\\server_1\C\MYDB"



Thanks a lot.

 
Yes should work..Note the following

sDataBaseName="\\Server\Directory\MyMDB.mdb"

if you have problem..use the commondialog control to check the right path..do the following

---------------------------

Dim cnn As New ADODB.Connection
Dim strcnn As String
dim sDataBaseName as string
Dim rs As New ADODB.Recordset

CommonDialog1.ShowOpen
sDataBaseName= CommonDialog1.Filename
cnn.ConnectionString = "ODBC;DBQ=" & sDataBaseName & ";UID=;PWD=;Driver={Microsoft Access Driver (*.mdb)}"
cnn.Open

------then your code.----

The above will help you make sure that you are passing the right path of the MDB. Once you get the right path get rid of the Common dialog and pass the path directly to sDataBaseName.

P.S Make sure to have a referance to Windows common dialog control.

Thanks Murali Bala
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top