Access databases in Medium Trust

Last post 03-05-2007 11:58 PM by Dsypher. 4 replies.

Sort Posts:

  • Access databases in Medium Trust

    05-10-2005, 7:55 AM
    • Member
      122 point Member
    • littlecharva
    • Member since 12-16-2003, 7:46 AM
    • Posts 31

    Hi,

    My new ASP.NET webhost, who had told me prior to ordering that I could use Access databases, has now told me that they operate a Medium Trust environment, and so the OleDb is off limits.  Having confronted them about this, they sent back:

    You do not need OLEdb permissions to access an Access DB on the server. We've heard reports of many successful attempts to use Access DB's without changing any environment settings.

    So, is this true?  Can I use an Access database without using System.Data.OleDb?

    Little'un

  • Re: Access databases in Medium Trust

    05-10-2005, 11:11 AM
    • Contributor
      5,370 point Contributor
    • JawadKhan
    • Member since 03-09-2005, 12:41 AM
    • Toronto, Canada
    • Posts 1,066

    You can use ODBC besides OleDB as follows:

    For Access (JET) ODBC Driver

    Imports System.Data.Odbc;

    OdbcConnection oODBCConnection = new OdbcConnection();

    oODBCConnection.ConnectionString = "Driver={Microsoft Access Driver (*.mdb)};" +
    "Dbq=" + Server.MapPath(".") + "MDBPathMDBName.mdb;" +
    "Uid=Admin;" +
    "Pwd=";
    oODBCConnection.Open();

    For Access (JET) OLE DB Provider

    using System.Data.OleDb;

    OleDbConnection oOleDbConnection = new OleDbConnection();

    oOleDbConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" +
    "Data Source=" + Server.MapPath(".") + "MDBPathMDBName.mdb;" +
    "User ID=Admin;" +
    "Password=";
    oOleDbConnection.Open();

    OLEDB vs ODBC -- Which should you use?
    Given the option, it's a no brainer to use OLEDB over ODBC. But if you are restricted as you mentioned by your ISV then ODBC might be an option.ODBC has been
    around for years and is based on older and more bug laden technology. Therefore, ALWAYS use OLEDB if your server/host supports it. Microsoft even says it themselves:

    When running Microsoft Jet in an IIS environment, it is recommended that you use the native Jet OLE DB Provider in place of the Microsoft Access ODBC driver. The Microsoft Access ODBC driver (Jet ODBC driver) can have stability issues due to the version of Visual Basic for Applications that is invoked because the version is not thread safe. As a result, when multiple concurrent users make requests of a Microsoft Access database, unpredictable results may occur. The native Jet OLE DB Provider includes fixes and enhancements for stability, performance, and thread pooling (including calling a thread-safe version of Visual Basic for Applications).
  • Re: Access databases in Medium Trust

    05-11-2006, 1:23 PM
    • Member
      323 point Member
    • Dsypher
    • Member since 11-29-2005, 11:46 AM
    • Posts 93
    Hi,

    Im facing exactly the same problem. As Jawad mentioned, I could use ODBC but my app has a GridView control which is bound to an AccessDataSource control which uses OleDb. So how can I make the AccessDataSource control use ODBC?

    I get the following exception when I load my page after uploading it to the server:

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

    Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Data.OleDb.OleDbPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

    Be nice to geeks, you might end up working for one

    Please hit "MARK AS ANSWER" if I made you smile today ;)
  • Re: Access databases in Medium Trust

    03-05-2007, 1:40 PM
    • Member
      14 point Member
    • DhanrajSeri
    • Member since 01-19-2007, 3:22 PM
    • Posts 11

    Hi,

    Did you get this one resolved?, if yes, could you please provide me a resolution?. Thanks.

    007
  • Re: Access databases in Medium Trust

    03-05-2007, 11:58 PM
    • Member
      323 point Member
    • Dsypher
    • Member since 11-29-2005, 11:46 AM
    • Posts 93
    DhanrajSeri:

    Hi,

    Did you get this one resolved?, if yes, could you please provide me a resolution?. Thanks.

     Ya I did. I moved my Database to a different server where they dont have these stupid restrictions.
     

    Be nice to geeks, you might end up working for one

    Please hit "MARK AS ANSWER" if I made you smile today ;)
Page 1 of 1 (5 items)