PDA

View Full Version : Cannot Write To Access Database


nh_capricorn
09-03-2004, 04:36 AM
I have an Access database located under /htdocs/_database. I also have a Web Services application, located at /htdocs/AppName. For some reason, I cannot write to the database. The original code worked on my local PC, but it does not work when I upload the program to the site. Is there something I'm missing? What about the relative path (what is it)?

This is the code I'm using to try and connect:

OleDbConnection conn = new OleDbConnection (
"Provider=Microsoft.Jet.OleDb.4.0; Data Source=" +
Server.MapPath( "\htdocs\_database/Test.mdb" ) );

I also tried using a fully-qualified path, but that didn't work either:

string dir = "e:\\web\\smarttech\\htdocs\\_database\\test.mdb";
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;" +
@"Data source="+dir+"test.mdb";

Any help would be greatly appreciated.

Scott
09-03-2004, 05:05 AM
Try this for the connection string:
Provider=Microsoft.Jet.OleDb.4.0; Data Source="e:\web\smarttech\htdocs\_database\test.mdb";

nh_capricorn
09-03-2004, 07:16 AM
Thanks Scott! That worked just fine.