applications allways looking on c:/ regardless of connection string

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gobblegob
    New Member
    • Dec 2007
    • 133

    applications allways looking on c:/ regardless of connection string

    for some reason my application is looking for my database in the wrong place
    i get an error "cannot find C:/database.accdb"


    Code:
      Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\database.accdb")
            Dim cmd As New OleDbCommand("SELECT COUNT(*) FROM [users] WHERE Fname = @Fname AND Lname = @Lname AND Password = @Password", conn)
    this is in my app.config aswell
    Code:
     connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\database.accdb"
                providerName="System.Data.OleDb" />
    i have searched the whole solution from "C:/database.accdb" but it is nowhere any ideas?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    Its on your F: drive

    Comment

    • tlhintoq
      Recognized Expert Specialist
      • Mar 2008
      • 3532

      #3
      Sorry... just being funny.

      i have searched the whole solution for "C:/database.accdb" but it is nowhere any ideas?
      Data Source=\databas e.accdb
      It's right here. I'm pretty sure that this causes it to look on the same drive as the running application, which in your case is C:

      I suggest you read through these tutorials:
      Database How to parts 1 and 2

      Comment

      • gobblegob
        New Member
        • Dec 2007
        • 133

        #4
        i got it now changed this
        Code:
        Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\database.accdb")
        to,,,
        Code:
        Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\database.accdb")

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          All you needed was a fully qualified path

          Comment

          Working...