none
help with ODBC connection to Access from .Net 2.0 RRS feed

  • Question

  • Hi there.

    I'm trying to connect from .Net 2.0 to a remote Access database. (not my choice,by the way)

     

    So everything works well enough on my laptop. But when i try it on the production box, i get a connectivity error (below). I checked the ODBC settings and they look the same between my box and the production box. And the web.config is the same too.

    WHAT am i missing? Any help is apprecianted (I don't have enough hair left to pull out ;-)

    This is set up under "system DSN" so i think everyone should have privs to see it?

     

    Here is the conection string:

    <add name="ConnectionString" connectionString="Dsn=ProblemManagementDB"

    providerName="System.Data.Odbc" />

     

    Here is the error:

    System.Data.Odbc.OdbcException: ERROR [HY024] [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
    ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
    ERROR [HY024] [Microsoft][ODBC Microsoft Access Driver] '(unknown)' is not a valid path.  Make sure that the path name is spelled correctly and that you are connected to the server on which the file resides.
       at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
       at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
       at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
       at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup)
       at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
       at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
       at System.Data.Odbc.OdbcConnection.Open()
       at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       at System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments)
       at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback)
       at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
       at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
       at System.Web.UI.WebControls.GridView.DataBind()
       at System.Web.UI.Control.DataBindChildren()
       at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
       at System.Web.UI.Control.DataBind()
       at System.Web.UI.Control.DataBindChildren()
       at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding)
       at System.Web.UI.Control.DataBind()

     

    (as you can tell, i'm not really an "ODBC guy" -- I think the last time i touched it was 8 years ago?)

    SO any ideas on this? I'm pretty sure the location of the mdb file is correct in the odbc setting (it is going through a mapped drive, though). But it is completely stable locally, but unable to work non-locally.

    Any thoughts would earn my grattitude.

    -- K

     
    Monday, November 5, 2007 4:33 PM

Answers

  • I would recommend using a UNC path instead. There is no guarantee that the mapped path (drive letter) will be available. I would suspect that since this is an ASP.NET app that the account under which your application process is executing cannot see the mapping.

     

    Tuesday, November 6, 2007 1:33 PM

All replies

  • I would recommend using a UNC path instead. There is no guarantee that the mapped path (drive letter) will be available. I would suspect that since this is an ASP.NET app that the account under which your application process is executing cannot see the mapping.

     

    Tuesday, November 6, 2007 1:33 PM
  • Let me see if i can get that changed. Thank you for your thoughts. I'll let you know if that helps.

     

    ===

     

     

    got it changed and i'm getting a different error.

    Again, I get this on the production server but not on my local box:

    System.Data.Odbc.OdbcException: ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)'; file already in use.
    ERROR [IM006] [Microsoft][ODBC Driver Manager] Driver's SQLSetConnectAttr failed
    ERROR [HY000] [Microsoft][ODBC Microsoft Access Driver] Could not use '(unknown)'; file already in use.
       at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
    I think it's strange that it would give me an "already in use error" from one box but not from another. And I'm not sure if the "Could not use '(unknown)'; file" is just another way of saying it still can't connect?
     
    Tuesday, November 6, 2007 4:19 PM
  • This is very likely a permissions problem. See the following:

     

    An unhandled exception may occur when you try to connect to an Access database from an ASP.NET worker process

     

    If you're running under Windows 2003 or later, the account referred to in the article is NetworkService and not ASPNET.

     

    Another article which should be helpful:

     

    INFO: Permissions to Connect to a Remote Access Database from ASP.NET

     

    Monday, November 12, 2007 2:59 PM