PDA

View Full Version : Connecting to Access DB


srhone
08-02-2004, 01:24 AM
This also worked but thanks for the help.

string strConn = @"Provider=Microsoft.Jet.OleDB.4.0;Data Source=E:\web\myDir\htdocs\_database\chemistry.mdb ;User ID=Admin";

[b]quote:Originally posted by bruce

You are using the wrong path.

use this instead

conn.ConnectionString = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=" & server.mappath("/_database/chemistry.mdb") & ";User ID=Admin";




[b]quote:Originally posted by srhone

I get an error connecting to my Access Db using Code-beind. The code is below can anyone help? The database is in the _database folder

The error I'm getting:
'c:\_database\chemistry.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.


The code:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=/_database/chemistry.mdb;User ID=Admin";
conn.Open();
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">

srhone
08-02-2004, 11:13 AM
I get an error connecting to my Access Db using Code-beind. The code is below can anyone help? The database is in the _database folder

The error I'm getting:
'c:\_database\chemistry.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.


The code:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=/_database/chemistry.mdb;User ID=Admin";
conn.Open();

bruce
08-02-2004, 12:14 PM
You are using the wrong path.

use this instead

conn.ConnectionString = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=" & server.mappath("/_database/chemistry.mdb") & ";User ID=Admin";




[b]quote:Originally posted by srhone

I get an error connecting to my Access Db using Code-beind. The code is below can anyone help? The database is in the _database folder

The error I'm getting:
'c:\_database\chemistry.mdb' is not a valid path. Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.


The code:
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = "Provider=Microsoft.Jet.OleDB.4.0;Data Source=/_database/chemistry.mdb;User ID=Admin";
conn.Open();
</blockquote id="quote"></font id="quote">