locked
Connection String in Access database RRS feed

  • Question

  • User1316246260 posted

    I am trying to get my connection string to work with a Microsoft Access database.

    This is what I have thus far:

    In web.config:

    <configuration>
      <connectionStrings>
        <add name="myConnString" connectionString="Data Source=|DataDirectory|\db1.mdb;Integrated Security=True;" providerName="System.Data.Oledb" />
      </connectionStrings>

    <configuration>

    In ASP.net:


        Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim strConn As String = System.Configuration.ConfigurationManager.ConnectionStrings("myConnString ").ConnectionString
            Dim Conn As New OleDbConnection(strConn)
            etc

    Thursday, June 6, 2013 12:19 PM

Answers

  • User1052662409 posted

    try this

    http://www.connectionstrings.com/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 10, 2013 1:51 AM

All replies

  • User1648350404 posted

    Try following:

     connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db1.mdb;"

    Make sure, your access database is in App_Data folder.

    Thursday, June 6, 2013 12:47 PM
  • User-691245060 posted

    check your connectionstring here - http://connectionstrings.com/access-2007

    also do let us know what is the error you are landing up with...

    thanks,

    Thursday, June 6, 2013 1:08 PM
  • User1316246260 posted

    Exception Details: System.Data.OleDb.OleDbException: 'E:\kunden\homepages\36\d457818200\www\zAccess\App_Data\db1.mdb' is not a valid path.

    My server path is 'E:\kunden\homepages\36\d457818200\www\'

    The folder that contains my asp.net program is "zAccess" which is linked to the website "access.mysite.com"

    I think "zAccess" is the problem here.

    It may run if that was not there?

    Thursday, June 6, 2013 1:31 PM
  • User-646145796 posted

    hi,

    your issue must be in

    <add name="myConnString" connectionString="Data Source=|DataDirectory|\db1.mdb;Integrated Security=True;" providerName="System.Data.Oledb" />

    as urenjoy says make sure your access database is in App_Data folder.

    your can refer to my connection string

      Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\SchoolDB.mdf;Integrated Security=True

    Hope it can help you

     

    Monday, June 10, 2013 1:06 AM
  • User1052662409 posted

    try this

    http://www.connectionstrings.com/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 10, 2013 1:51 AM
  • User-1716253493 posted
    <add name="myConnString"
    connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\db1.mdb"
    providerName="System.Data.OleDb" />

    Monday, June 10, 2013 2:40 AM