Opening Access Database on Hosting Service's Server inside ASP.NET App using Visual Studio 2003?

  • Thread starter Siegfried Heintze
  • Start date
S

Siegfried Heintze

I have a sample ASP.NET datagrid demonstration that works fine on my
notebook. Of course, it was created with Visual Studio 2003.

The project has been copied to a commercial hosting service's remote server.
Of course it did not work because the absoute path for the connection string
for the Access database was different on my notebook than on the remote
server.

So, I inserted some code to fetch the script_name, remove the file name from
the script_name and append the name of the Access Database. Then I send this
thru mappath. This technique worked fine on a second hosting service.

However, on this first hosting service, I get "The Microsoft Jet database
engine cannot open the file
C:\Inetpub\websites\evidence\stage\htdocs\demo_grid_asp.net\test_pce.mdb' It
is already opened exclusively by another user, or you need permissing to
view its data. This looks like the correct path on the remote server.

Wierd!

This is the connection string generated by Visual Studio! Hmmm.... Who else
could have it open?



Thanks,
Siegfried
 
S

Siegfried Heintze

Here is the code causing the problem:

Dim sScriptName As String =
Request.ServerVariables().Item("SCRIPT_NAME")
sPath = sScriptName.Substring(0, sScriptName.LastIndexOf("/"))
sPath = sPath.Substring(0, sScriptName.LastIndexOf("/"))
sPath = Server.MapPath(sPath)
Me.cnnAssertions.ConnectionString =
"Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source="
& sPath & "\" & _
"test_pce2.mdb;Mode=Share Deny None;Extended" & _
" Properties="""";Jet OLEDB:System database="""";Jet OLEDB:Registry
Path="""";Jet OLEDB" & _
":Database Password="""";Jet OLEDB:Engine Type=5;Jet OLEDB:Database
Locking Mode=0;" & _
"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk
Transactions=1;Jet OLE" & _
"DB:New Database Password="""";Jet OLEDB:Create System
Database=False;Jet OLEDB:Enc" & _
"rypt Database=False;Jet OLEDB:Don't Copy Locale on
Compact=False;Jet OLEDB:Compa" & _
"ct Without Replica Repair=False;Jet OLEDB:SFP=False"
 
N

Norman Yuan

Your problem is mainly a ASP.NET security issue. Did yo know that user who
connects to Access db needs both read and write permission? (Whenever a
connection to the *mdb file is established, a *.ldb file is created at the
same location as the *.mdb file. When all connections to the *.mdb file are
gone, the *.ldb file is removed.

By default, ASP.NET app is run with ASPNET used account, which has limited
access permission. In your case, ASPNET user account obviously does not has
write permission the the folder where *.mdb is located.

You can:

1. Give ASPNET user account write permission to the folder where *.mdb
locates. It is very bad approach, though, if the ASP.NET app is run a public
accessible website.

2. Impersonate the ASP.NET user to a user account that has read/write
permission to the *.mdb folder.
 
S

Siegfried Heintze

Is this issue unique to ASP.NET?

I already have an Access database that has been used for years by CGI Perl
scripts. It is in a special directory though. So I pointed my ASP.NET
application to use that copy of the database and I still get the exact same
error message.

Since the Perl CGI is using the database, then the IIS process must have
read/write access to it. Correct?
 
B

Brendan Reynolds

I think this is a question that only your hosting service provider can
answer, Siegfried.
 
N

Norman Yuan

It is the same that internet users have very low level of pemission on web
server, whether the server is MS IIS or other web server, running ASP.NET or
CGI, or whatever app. It is rare that public website gives internet users
write permission. Any application (ASP.NET, CGI...) running on the web
server is under certain user account. In the case of IIS, if "anonymous"
access is allowed, by default, ASPNET user account is used to run ASP.NET
app. If impersonation is enabled, but not user account is specified in
web.confi file, then the default account to IIS is used
(ISUER_ComputerName). You probably need to do a bit study on basic ASP.NET
security before you put your ASP.NET on a commercial web host.

Since MS Access is a file database, user MUST have both read/write
permission to access it. I do not know how it was set up in your CGI, I'd
guess the CGI is run under different usser account other than the anonymous
internet user account on that server. Many web hosting services make MS
Access db for small website accessible through ODBC data source name(DSN).
Check out this possibility with your service provider. Yes, as Brendan
Reynolds suggested in the other post, you should contact your service
provider to discuss this issue.
 

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