Help Please! Connect to Access database on a server?

Discussion in 'ASP.NET / ASP.NET Core' started by chriscanali, Jun 28, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I can't for the life of me figure out the connection string to connect to an Access database on a server. Everything I have found searching is just for connection to a local .mdb (onmy hard drive). Well I am making a site with amultiple choice test and need to store the data in an Access database. This is possible right? How do I get connected? Thanks very much for any help!
     
  2. I answered my own question again, sorry for another unneccesary post. I saw Bruce's replys to a few posts stating that you cannot connect to an Access database on a server. But if anyone else knows differant please let me know.
     
  3. Yes, you can connect to an Access database on the DASP server. The most commom method is to put the connection string in your web config file as follows:
     
  4. I'm also having trouble connecting to an Access DB on the server.



    Dim conn As New System.Data.OleDb.OleDbConnection



    conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("/testapp/dbtest/sportingclays.mdb")





    It tries to map to my local machine, and I get the error:



    Server Error in '/testapp/dbtest' Application.


    'C:\Documents and Settings\current\Local Settings\Temporary Internet Files\Content.IE5\ATWF6965\SportingClays[1].mdb' 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.


    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: 'C:\Documents and Settings\current\Local Settings\Temporary Internet Files\Content.IE5\ATWF6965\SportingClays[1].mdb' 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.

    Source Error:





    Code:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:





    Code:
    [OleDbException (0x80004005): 'C:\Documents and Settings\current\Local Settings\Temporary Internet Files\Content.IE5\ATWF6965\SportingClays[1].mdb' 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.]
       System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
       System.Data.OleDb.OleDbConnection.InitializeProvider() +57
       System.Data.OleDb.OleDbConnection.Open() +203
       System.Data.Common.DbDataAdapter.QuietOpen(IDbConnection connection, ConnectionState& originalState) +44
       System.Data.Common.DbDataAdapter.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +304
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +77
       System.Data.Common.DbDataAdapter.Fill(DataSet dataSet) +38
       dbtest.WebForm1.Page_Load(Object sender, EventArgs e) +132
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +750
    

    ==========================================================


    If I make a minor (but invalid) change to the connect string (removed testdb from directory string), I get an error that looks like it is correctly trying to map to the server directory:


    conn.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("/testapp/sportingclays.mdb")


    I get the error:



    Server Error in '/testapp/dbtest' Application.


    Could not find file 'E:\web\xxxxxxcom00\htdocs\testapp\sportingclays.mdb'.


    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Data.OleDb.OleDbException: Could not find file 'E:\web\cclosecom00\htdocs\testapp\sportingclays.mdb'.

    Source Error:





    Code:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
    Stack Trace:





    Code:
    [OleDbException (0x80004005): Could not find file 'E:\web\xxxxxxcom00\htdocs\testapp\sportingclays.mdb'.]
       System.Data.OleDb.OleDbConnection.ProcessResults(Int32 hr) +20
       System.Data.OleDb.OleDbConnection.InitializeProvider() +57
       System.Data.OleDb.OleDbConnection.Open() +203
       dbtest.WebForm1.Page_Load(Object sender, EventArgs e) +92
       System.Web.UI.Control.OnLoad(EventArgs e) +67
       System.Web.UI.Control.LoadRecursive() +35
       System.Web.UI.Page.ProcessRequestMain() +750
    

    ===============================


    Any help will be greatly appreciated! It's driving me a little nutz!
     
  5. I found the problem. Had another old connect string in an OleDbConnection object...[​IMG]
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page