MS Access database on Windows 2003 web server

A

Art Levin

Hi Kevin,

Thanks for getting back to me.

I am using C# with asp.net to access the database.

Below is the code that I am using to access the two tables.

string DataBaseName;

string SelectCommand;

NameValueCollection coll;

coll = Request.ServerVariables;

DataBaseName = coll.Get("APPL_PHYSICAL_PATH");

DataBaseName += "Databases\\db.mdb";

OleDbConnection CustomerConnection = new OleDbConnection(

@"Provider=Microsoft.Jet.OLEDB.4.0;"+

@"Data Source= " + DataBaseName);

OleDbCommand CustomerCommand = new OleDbCommand(

"SELECT * FROM Customers WHERE UserId = ?" ,CustomerConnection );
CustomerConnection.Open();
CustomerCommand.Parameters.Add("UserId",Session["UserId"].ToString());

CustomerReader = CustomerCommand.ExecuteReader(); CustomerReader.Read();



OleDbConnection StateConnection = new OleDbConnection(

@"Provider=Microsoft.Jet.OLEDB.4.0;"+

@"Data Source= " + DataBaseName);

SelectCommand = "SELECT * FROM States";

StateCommand = new OleDbCommand(SelectCommand ,StateConnection );
StateConnection.Open(); StateReader = StateCommand.ExecuteReader();

while(StateReader.Read() == true)



Table 1 is still open when I access table 2.

If I only have 1 table opened at a time I don't seem to have any problems.



Here is what I get when I access the web site.

Server Error in '/' Application.

Could not use ''; file already in use.

Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Data.OleDb.OleDbException: Could not use ''; file
already in use.

Source Error:

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.

Stack Trace:



[OleDbException (0x80004005): Could not use ''; file already in use.]

System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20

System.Data.OleDb.OleDbConnection.InitializeProvider() +57

System.Data.OleDb.OleDbConnection.Open() +203

VeitchFulfillment.Fulfillment.AddressInformation.Init0() in
c:\inetpub\wwwroot\veitchfulfillment\fulfillment\addressinformation.aspx.cs:
230

VeitchFulfillment.Fulfillment.AddressInformation.OnInit(EventArgs e) in
c:\inetpub\wwwroot\veitchfulfillment\fulfillment\addressinformation.aspx.cs:
836

System.Web.UI.Control.InitRecursive(Control namingContainer) +241

System.Web.UI.Page.ProcessRequestMain() +174






I compared the setup of the database in windows explorer and in IIS with the
2000 machine. They seem to be identical.

Yes there is a .ldb file in the folder with the mdb

This is the only database I have at this time.

This is working fine on Windows 2000 Server with IIS 5.

It also works fine on my development machine. Windows XP Workstation.

Does this have anything to do with MSDE.

Does MSDE have to be installed manualy on the web server.



I hope you can help me.



Thank again.

Art Levin
 
K

Kevin Sun [MS]

Hi Art,

I have reviewed the code you provided, it seems to be fine.

In this case, this problem may be related to the configuration of the
ASP.NET, especially the ASP permission to the .mdb file and its folder.

Please refer to the following article:

PRB: Cannot Connect to Access Database from ASP.NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;316675

INFO: Permissions to Connect to a Remote Access Database from ASP.NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;307901

In addition, I suggest you to create a new database to test this problem to
identify whether or not this problem is relate to the database itself

Sincerely,

Kevin
Microsoft Support

This posting is provided "AS IS" with no warranties, and confers no rights.
Get Secure! - www.microsoft.com/security

--------------------
| From: "Art Levin" <[email protected]>
| Subject: MS Access database on Windows 2003 web server
| Date: Mon, 30 Jun 2003 12:42:43 -0400
| Lines: 131
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.adonet
| NNTP-Posting-Host: pool-68-162-11-193.nwrk.east.verizon.net 68.162.11.193
| Path: cpmsftngxa09.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa09.phx.gbl microsoft.public.dotnet.framework.adonet:9557
| X-Tomcat-NG: microsoft.public.dotnet.framework.adonet
|
| Hi Kevin,
|
| Thanks for getting back to me.
|
| I am using C# with asp.net to access the database.
|
| Below is the code that I am using to access the two tables.
|
| string DataBaseName;
|
| string SelectCommand;
|
| NameValueCollection coll;
|
| coll = Request.ServerVariables;
|
| DataBaseName = coll.Get("APPL_PHYSICAL_PATH");
|
| DataBaseName += "Databases\\db.mdb";
|
| OleDbConnection CustomerConnection = new OleDbConnection(
|
| @"Provider=Microsoft.Jet.OLEDB.4.0;"+
|
| @"Data Source= " + DataBaseName);
|
| OleDbCommand CustomerCommand = new OleDbCommand(
|
| "SELECT * FROM Customers WHERE UserId = ?" ,CustomerConnection );
| CustomerConnection.Open();
| CustomerCommand.Parameters.Add("UserId",Session["UserId"].ToString());
|
| CustomerReader = CustomerCommand.ExecuteReader(); CustomerReader.Read();
|
|
|
| OleDbConnection StateConnection = new OleDbConnection(
|
| @"Provider=Microsoft.Jet.OLEDB.4.0;"+
|
| @"Data Source= " + DataBaseName);
|
| SelectCommand = "SELECT * FROM States";
|
| StateCommand = new OleDbCommand(SelectCommand ,StateConnection );
| StateConnection.Open(); StateReader = StateCommand.ExecuteReader();
|
| while(StateReader.Read() == true)
|
|
|
| Table 1 is still open when I access table 2.
|
| If I only have 1 table opened at a time I don't seem to have any problems.
|
|
|
| Here is what I get when I access the web site.
|
| Server Error in '/' Application.
|
| Could not use ''; file already in use.
|
| Description: An unhandled exception occurred during the execution of the
| current web request. Please review the stack trace for more information
| about the error and where it originated in the code.
|
| Exception Details: System.Data.OleDb.OleDbException: Could not use '';
file
| already in use.
|
| Source Error:
|
| An unhandled exception was generated during the execution of the current
web
| request. Information regarding the origin and location of the exception
can
| be identified using the exception stack trace below.
|
| Stack Trace:
|
|
|
| [OleDbException (0x80004005): Could not use ''; file already in use.]
|
| System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
|
| System.Data.OleDb.OleDbConnection.InitializeProvider() +57
|
| System.Data.OleDb.OleDbConnection.Open() +203
|
| VeitchFulfillment.Fulfillment.AddressInformation.Init0() in
|
c:\inetpub\wwwroot\veitchfulfillment\fulfillment\addressinformation.aspx.cs:
| 230
|
| VeitchFulfillment.Fulfillment.AddressInformation.OnInit(EventArgs e) in
|
c:\inetpub\wwwroot\veitchfulfillment\fulfillment\addressinformation.aspx.cs:
| 836
|
| System.Web.UI.Control.InitRecursive(Control namingContainer) +241
|
| System.Web.UI.Page.ProcessRequestMain() +174
|
|
|
|
|
|
| I compared the setup of the database in windows explorer and in IIS with
the
| 2000 machine. They seem to be identical.
|
| Yes there is a .ldb file in the folder with the mdb
|
| This is the only database I have at this time.
|
| This is working fine on Windows 2000 Server with IIS 5.
|
| It also works fine on my development machine. Windows XP Workstation.
|
| Does this have anything to do with MSDE.
|
| Does MSDE have to be installed manualy on the web server.
|
|
|
| I hope you can help me.
|
|
|
| Thank again.
|
| Art Levin
|
|
|
 

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