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?

Hi
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

at first we want to create new MS Access Database by Giving path from Textbox instead of prewritten path on Runtime in vb. net

Imports ADOX Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Try
    Dim cat As Catalog = New Catalog()

    cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
                "Data Source=C:\Users\Anish Choudhary\Desktop\New folder\N.mdb;" & _
                "Jet OLEDB:Engine Type=5")

    MessageBox.Show("Database Created Successfully")

    cat = Nothing

Catch ex As Exception
    MessageBox.Show("Database already Exists")
End Try

End Sub
End Class

<snip>

Now I will try the proposed options.

I have a VB. ... Net program compose information to an Access database on Windows 7 from the setup. ... To put it plainly, the way to the database document ought to be ...

I'll declare this variable as public in the db class. That way the program will always search the root diretory of the application for the database.

If you use a global database and the path changes you could implement an ini or config file.
The easy way of doing that is creating a textfile with the ending .ini and add the path as a string in there.
Then place it in the root of your application again.

In the start of your program you'll read through the ini file and get the path of the database.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.