English 中文(简体)
connect Access via c#
原标题:

i need to open a connection to a remote access db. in the local environment to the remote acess db is working great . when i run this application from production server (other server) it s fail with message

" It is already opened exclusively by another user, or you need permission to view its data. "

my code :

   conString =
       @"Provider=Microsoft.JET.OLEDB.4.0;"
     + @"data source=" \150.248.248.38d$TestAppvending.mdb;Jet OLEDB:Database Password=1234;";

      OleDbConnection connAccess = new OleDbConnection(conString);


    try
    {

        connAccess.Open();

        objDiningRoom.Connection = connAccess;

       ....
    }
    catch (Exception ex)
    {


    }
    finally
    {
        connAccess.Close();
        connAccess.Dispose();
    }

*Its not open in other place thanks

问题回答

This looks like it is a permissions problem. Make sure you give the IUSR account (or whatever account ASP.NET runs as) read/write permissions to your database.

you can try :here copied from there :

  • This commonly occurs when your database file is opened exclusively
    by another application (usually MS
    Access). Close all applications that
    use this database and try again.
  • This error may occur if the account being used by Internet Information
    Server (IIS), (usually IUSR), does
    not have the correct Windows NT
    permissions for a file-based database or for the folder containing the
    file.
  • Check the permissions on the file and the folder. Make sure that you have the ability to create and/or destroy any temporary files. Temporary files are usually created in the same folder as the database, but the file may also be created in other folders such as /Winnt. If you use a network path to the database (UNC or mapped drive), check the permissions on the share, the file, and the folder.
  • Check to make sure that the file and the data source name (DSN) are not marked as Exclusive.
  • Simplify. Use a System DSN that uses a local drive letter. Move the database to the local drive if
    necessary to test.
  • The "other user" might be Visual InterDev. Close any Visual InterDev
    projects that contain a data
    connection to the database.
  • This error may also occur when accessing a local Microsoft Access
    database linked to a table where the
    table is in an Access database on a
    network server. In this situation,
    please refer to the following article in the Microsoft Knowledge Base for a workaround: Q189408 PRB: ASP Fails to Access Network Files Under IIS 4.0




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签