0

Hi! I have a vb.net project on a jump drive that connects to an Access (2003) database (located on the jump drive). My problem is when I change computers, I have to change the drive letter the jump drive is located. Currently, I have the following code and have to comment out the connection to the letter drives I do not need to use.

' Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\Grad Project\Project.mdb;")
        ' Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=F:\Grad Project\Project.mdb;")
        'Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=N:\Grad Project\Project.mdb;")

I have been told I can create a procedure so that I only have to change the letter drive in one place and then each time I need to connect to the database, I can call that procedure.

Any idea how I would do this/code this?

Thanks!

Edited by rhonda2010: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by __avd
0

Store connection string in app.config or Put your databases inside the folder where your executable is and use |DataDirectory|.

Dim con As OleDbConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=|DataDirectory|\Project.mdb;")
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.