1
Answer

How to use the relative path to connect the MS Access

nan

nan

16y
8k
1

I have build a connection from VB.net form to a MS Access database "AddressBook.mdb", the code below is working

    Me.AddressBookConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=C:\Documents and Settings\thiago\Desktop\data\AddressBook.mdb"

The above code is a absolute path, I would like to change it to a relative path, hence I change the code to:

Me.AddressBookConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=" & server.mappath("../data/AddressBook.mdb")

but the Visual Studio indicated the name server is not declared, this project is just the form to connect the database, without any other type files, how can I change the absolute path to the relatvie path here?


Answers (1)