|
-
Nov 2nd, 2005, 10:15 PM
#1
Thread Starter
New Member
ConnectionString to Database
I have a problem and I am unsure how to go about it. I am creating a simple vb.net program that uses MS Access as a backend. I place the database in c:\data\data.mdb. In the visual basic designer on one of the forms, I have a odbcconnection object where inside the connectionstring property it points to the database on my machine. I then have controls that look toward a command object which in turns looks through the connection object.
My problem is, what if I package the program up and gave it to someone else to install. The database on thier computer will not be in c:\data\data.mdb. Therefore the connectionstring in the command object is incorrect because the connectionstring is based where I had the database and not where it is on the users machine.
How do you go about creating a program where multiple individuals will install the program and you have to adjust the connectionstring to where the database is on thier computer?
-
Nov 2nd, 2005, 10:26 PM
#2
Re: ConnectionString to Database
First off, you should really choose OleDb over OdbcClient when working with Access.
Oftentimes you will put the database in a subfolder of your application folder, in which case you can use Application.StartupPath to build the full path. Alternatively, you could store your connection string in the config file and then either manually or in code edit it for each installation. You would generally use an OpenFileDialog or SaveFileDialog to let the user select the database location and then build the path into your connection string if you wanted to do it in code. Note that ConnectionString is a dynamic property so you can store it in the config file with just a few mouse clicks.
http://msdn.microsoft.com/library/de...albasicnet.asp
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|