Can only write to root of disk

G

Guest

I am having a problem writing to an Access database. It only seems to work if the database is placed in c:\
Retrieving records from it is no problem when it is placed in a subdirectory of mapppath, but writing to it is impossible (unless I put it in c:\).

This is the code that refuses to work:
Dim myConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & MapPath("db\users.mdb") & ";Jet OLEDB:Database Password=123;"

This is the code that works for me:
Dim myConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\users.mdb" & ";Jet OLEDB:Database Password=nt2123;"

The mappath dir and the \db dir as well as the database file itself have read and write permissions.

Why does it not work???
 
P

Phill. W

.. . .
This is the code that refuses to work:
Dim myConString As String _
= "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & MapPath("db\users.mdb") & ";" _
& "Jet OLEDB:Database Password=123;"

Looks like you're written your own MapPath function (usually
provided by the Server object?) or you have On Error Resume Next
work against you.

Perhaps this might work better :
Dim myConString As String _
= "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.MapPath("/db/users.mdb") & ";" _
& "Jet OLEDB:Database Password=123;"

HTH,
Phill W.
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

In addition to the suggestion you have already received in this group,
your ASPNET account may not have access to this folder. If the users are
able to access the folder, consider forcing authentication and using
impersonation. If not, you will have to give ASPNET access to the /db
folder.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
Eric J. said:
I am having a problem writing to an Access database. It only seems to work
if the database is placed in c:\
Retrieving records from it is no problem when it is placed in a
subdirectory of mapppath, but writing to it is impossible (unless I put it
in c:\).
This is the code that refuses to work:
Dim myConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & MapPath("db\users.mdb") & ";Jet OLEDB:Database Password=123;"
This is the code that works for me:
Dim myConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\users.mdb" & ";Jet OLEDB:Database Password=nt2123;"
 
J

Jos

Phill. W said:
. . .

Looks like you're written your own MapPath function (usually
provided by the Server object?) or you have On Error Resume Next
work against you.

Perhaps this might work better :


HTH,
Phill W.

MapPath() is also a method of the Page object.
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

Using XP, I take it.

By default, you do not have a security tab in XP. To turn this on, the drive
must be NTFS (if I remember correctly). Go to Windows Explorer and use Toolsnow be able to set security correctly to allow ASPNET to work with it.

Since this is the ASP .NET group, I assume you are not using XP Home, which
does not allow you to turn off Simple File Sharing (perhaps a registry
hack?).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
Eric J. said:
I have set verification to Anonymous (IUSR) and read/write to true in the
ISS system tool. I have given read/write access to all users via the
security tab in Explorer. I only can't set the ' Read Only checkbox' in the
properties of the folder to False. It keeps changing back to True.
 
G

Guest

Using XP, I take it.

Yes, indeed
By default, you do not have a security tab in XP. To turn this on, the drive
must be NTFS (if I remember correctly). Go to Windows Explorer and use Tools
now be able to set security correctly to allow ASPNET to work with it.

Since this is the ASP .NET group, I assume you are not using XP Home, which
does not allow you to turn off Simple File Sharing (perhaps a registry
hack?).

No, XP Pro. I did all that. Gave read/write permission to everyone. Still no succes. If I change the connection string to the specified folder it works also ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\Totaal\db\users.mdb;Jet OLEDB:Database Password=2123). Just not when I am referring to the folder using MapPath. (DataSource=" & MapPath("db\users.mdb")
 
G

Guest

Found it!!

Changing to
Dim myConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & Server.MapPath("/db/users.mdb") & ";" _
& "Jet OLEDB:Database Password=123;"

does the trick. Thank you Phil and the rest. Why can't MS produce some better error messages...?
 

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

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top