Click to See Complete Forum and Search --> : DAO working from Windows App, but not Web App


fatbuddha
July 15th, 2002, 02:00 PM
In order to allow my C# Windows Application to use DAO 3.6, I include "Microsoft DAO 3.60" using the add references command, and add the following line to the source code:

using DAO;

I then put the following code, which establishes a connection to a database, into the main function:

DBEngine myDBEngine = new DBEngineClass();
Workspace myWorkspace = myDBEngine.CreateWorkspace("ODBCWorkspace", "Admin", "", WorkspaceTypeEnum.dbUseODBC);
Database myDatabase = myWorkspace.OpenDatabase("MyDNS", DriverPromptEnum.dbDriverNoPrompt, true, "ODBC;");

This all works fine, and I can make recordsets and retrieve records etc.

Now I use exactly the same technique and code in a Web Application project, but this time I get the exception thrown "ODBC--call failed" on the OpenDatabase() call. I've tried ODBC tracing and found a more detailed error:

DIAG [S1000] [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data. (-1032)

The file is certainly not locked exclusively by another user, and so I must assume that there is permission problems. I've tried setting the IIS servers settings to minimum protection wherever possible - but still the same problem occurs. Weird eh?

Well I'm stumped on this one - so if any of the gurus could point me in the right direction, I'd be mighty grateful.

Rob Smith

jparsons
July 15th, 2002, 03:00 PM
Originally posted by fatbuddha
In order to allow my C# Windows Application to use DAO 3.6, I include "Microsoft DAO 3.60" using the add references command, and add the following line to the source code:

using DAO;

I then put the following code, which establishes a connection to a database, into the main function:

DBEngine myDBEngine = new DBEngineClass();
Workspace myWorkspace = myDBEngine.CreateWorkspace("ODBCWorkspace", "Admin", "", WorkspaceTypeEnum.dbUseODBC);
Database myDatabase = myWorkspace.OpenDatabase("MyDNS", DriverPromptEnum.dbDriverNoPrompt, true, "ODBC;");

This all works fine, and I can make recordsets and retrieve records etc.

Now I use exactly the same technique and code in a Web Application project, but this time I get the exception thrown "ODBC--call failed" on the OpenDatabase() call. I've tried ODBC tracing and found a more detailed error:

DIAG [S1000] [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view its data. (-1032)

The file is certainly not locked exclusively by another user, and so I must assume that there is permission problems. I've tried setting the IIS servers settings to minimum protection wherever possible - but still the same problem occurs. Weird eh?

Well I'm stumped on this one - so if any of the gurus could point me in the right direction, I'd be mighty grateful.

Rob Smith

I don't know much at all about DAO but it sounds to me like you're getting a permissions error. Doesn't the Web server run as user nobody? Could that be affecting your application?

CPCericola
July 17th, 2002, 08:50 AM
Does the IUSR_ account have read/write access to the file? If not, that's probably your issue.