General discussion

Locked

How to connect a database?

By MsDelaine ·
In the Control Panel under Administrative Tools in Windows 2000, Data Sources (ODBC) how do I connect my Microsoft Access database? Also in VB 6.0 in my Module how do I code the connection? I know how in Windows 98 and using ADODB. See below.Public Sub open_access()

Set Delaine= New ADODB.Connection

Delaine.Provider = "Microsoft OLE DB Provider.ODBC;Persist Security Info=False;"
Delaine.ConnectionString = "Data Source = " & App.Path & "\CricketWorks.mdb"

End Sub

Please help me.

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

How to connect a database?

by andrew In reply to How to connect a database ...

The Data Sources (ODBC) utility is used to create DSNs for you to access databases. You need create an ODBC DSN that points to your Access DB.

On the 'System DSN' tab, click on the 'Add' button and select the Microsoft Access Driver (*.mdb), thenclick 'Finish'

On the next dialog, name the DSN (let's call it 'AccessTest') and click on 'Select' and browse to the MDB file. If you need security, enter the credentials in the 'Advanced' dialog. Click 'OK'.

In VB, you can use just the DSN asa connection string:

Dim oCon as ADODB.Connection
Set oCon = New ADODB.Connection
oCon.Open "AccessTest"

Now that I've told you all this, I recommend you don't use it. Just use a pure OLEDB connection (DSN-less):

Dim oCon As ADODB.Connection
Set oCon = New ADODB.Connection
oCon.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DBFileName.mdb;"

This will be much faster, and you don't have to mess with ODBC.

Collapse -

How to connect a database?

by MsDelaine In reply to How to connect a database ...

Poster rated this answer

Collapse -

How to connect a database?

by MsDelaine In reply to How to connect a database ...

This question was closed by the author

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums