ASP.NET & Access Database!


B

blantz

I am trying to connect to an Access database on a network drive and
the web server is on the same network, i.e. G:\sample\test.mdb and
everytime I try to connect to it I get an error saying...
'G:\sample\test.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. I then tried giving the full path to the server,
i.e. \\webserver\c:\inetpub\... but got the same error.

When I move the database to my local computer it works fine. Here is
the connection string I am trying to use.

Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=G:\sample\test.mdb;


When I connect via regular ASP using this custom connection string,
everything works correct... any ideas?

"Driver={Microsoft Access Driver (*.mdb)}; Dbq=G:\sample\test.mdb"
 
Ad

Advertisements

S

Steve C. Orr [MVP, MCSD]

The default ASPNET user account doesn't have network permissions.
One solution is to change ASP.NET to run under a different account that has
the necessary permissions. For testing purposes I suggest having it run
under your user account since you know you have permission.

For example, you can add a line similar to this to your web.config file:
<identity impersonate="true" userName="domain\MyAppUser">
password="password"/>

Here's more info on impersonation:
http://msdn.microsoft.com/library/d...-us/cpguide/html/cpconaspnetimpersonation.asp
 
G

Guest

You have G:\ hardcoded, is the web server have also have the G:\ drive
pointing to the same share? Why not create a DSN on the web server to point
to your Access database? By doing this your code can just point to a DSN
name and not the actual database?
 
A

Andy Lim

try to use DSN, and refer to it in your connection string instead of
hardcoding your MDB location path.

HTH,
andy
 
Ad

Advertisements

Joined
Oct 9, 2007
Messages
1
Reaction score
0
The solution to this problem is simple. Use Server.MapPath("./path") to get the path at runtime. Remember to use ../, ./, or nothing before the relative path. Using / will cause an error.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top