Database Connection Problem on Deployment

owinterton

Member
Joined
Mar 18, 2003
Messages
12
Location
California
I am trying to develop my windows application and make the connection to the database as flexible as possible so that when I deploy it, the app will work on anyones computer and the user can identify the path where the database will live. I am new to VB.net so I have no clue as to how to set the connection string so that it will know where the path is at all times. Im working with VB.net for Windows apps and an Access database. I am trying to migrate the access database to an Windows 2000 SQL Server eventually. Any ideas out there to help solve my dilemma?
 
put your database into the ...\...\Bin\ directory,
then:
[VB]
Dim strPath As String = Application.StartupPath()
[/code]
ex:
Code:
Import System.Data.OleDb

Dim strConnection As String = _
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strPath & "\Northwind.mdb"
Dim cn As OleDbConnection = New OleDbConnection(strConnection)
cn.Open()
That should open the connection.
to close it:
Code:
cn.close()
 
Thanks SilverStormBoy. You have solved much of my frustration. I tried to set the connection string but I couldnt figure out how to make it work the way I wanted it. Thanks a bunch.
 
Back
Top