CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2000
    Posts
    50

    DAO working from Windows App, but not Web App

    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:
    PHP Code:
    using DAO
    I then put the following code, which establishes a connection to a database, into the main function:
    PHP Code:
    DBEngine myDBEngine = new DBEngineClass();
    Workspace myWorkspace myDBEngine.CreateWorkspace("ODBCWorkspace""Admin"""WorkspaceTypeEnum.dbUseODBC);
    Database myDatabase myWorkspace.OpenDatabase("MyDNS"DriverPromptEnum.dbDriverNoPrompttrue"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

  2. #2
    Join Date
    May 2002
    Location
    Atlanta,GA
    Posts
    262

    Re: DAO working from Windows App, but not Web App

    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:
    PHP Code:
    using DAO
    I then put the following code, which establishes a connection to a database, into the main function:
    PHP Code:
    DBEngine myDBEngine = new DBEngineClass();
    Workspace myWorkspace myDBEngine.CreateWorkspace("ODBCWorkspace""Admin"""WorkspaceTypeEnum.dbUseODBC);
    Database myDatabase myWorkspace.OpenDatabase("MyDNS"DriverPromptEnum.dbDriverNoPrompttrue"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?
    Jared

  3. #3
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85
    Does the IUSR_ account have read/write access to the file? If not, that's probably your issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured