Hi guys,
i'm having a difficulty to set the path in vb.net.i put the code in the module
and every time i run the code it throws error
"Could not find file 'C:\Users\Abdueie\Desktop\BMS\Bridge Asset Management\Bridge Asset Management\bin\Debug\Adigrat.accdb'."
here's the code

Public conn As OleDbConnection = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0; Data Source= .\Adigrat.accdb;Persist Security Info=False")

Are you sure the path is correct?

You can verify it by doing this:

If File.Exists("C:\Users\Abdueie\Desktop\BMS\Bridge Asset Management\Bridge Asset Management\bin\Debug\Adigrat.accdb") Then MsgBox("It is there!") Else MsgBox("Path May Be Wrong!")

My idea is that when you try to run the application on other pc how do you set the path?

Are you using a common networked database for all users? Or is it that you are deploying the database with the program i.e. one database per user?

commented: Forgot to ask! :) +8

A few things to check:

  • Is the file in the programs's Debug folder?
    C:\Users\Abdueie\Desktop\BMS\Bridge Asset Management\Bridge Asset Management\bin\Debug\
  • If not, are you selecting 'Copy to Output'.

i just tested that it runs currently well.but i was just curious that i had a sample vb.net app that runs fine without putting the db in debug folder.anyway tnx a lot

This is how i have it in my visual basic code

dbconn.ConnectionString = (“Provider=Microsoft.ACE.OLEDB.12.0;Data Source=” & Application.StartupPath & “\eddybase.accdb”)
Now how can i locate that path on the client pc because there i wont install visual studio on his conputer. Just want to install the window application and work well while i can see the ms access database as eddybase.accdb in his local disk(c) let me say docunent or anywhere.
And am not using any network.
Just want to install on one pc not sharing the database

lnstead of using a textbox to get a folder path use the appropriate control provided by the NET Library. It is called FolderBrowserDialog TextBoxes are not very good for this kind of operation. The user could have a lot of problems typing a correct path, instead a FolderBrowserDialog in its simplicity allows to reach the correct path without manually typing anything

Dim fbd = New FolderBrowserDialog()
fbd.Description = "Select a folder for the new database"
fbd.RootFolder = Environment.SpecialFolder.MyComputer
fbd.ShowNewFolderButton = True
If fbd.ShowDialog() = DialogResult.OK Then

    Dim filePath =  Path.Combine(fbd.SelectedPath, "N.mdb")
    Dim cat As Catalog = New Catalog()
    cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=" & filePath & _
                "Jet OLEDB:Engine Type=5")
    MessageBox.Show("Database Created Successfully")
    cat = Nothing
Catch ex As Exception
    MessageBox.Show("Database already Exists")
End Try

End If