Changing Data Source Location

G

Guest

I am new to .Net and working on my first program. I have created a Data
Source using the Data Source Configuration Wizard, and an Access database.
However, when I distribute this app, I will not have control over where the
database resides. How can I programmatically change the connection string in
the data set created by the wizard?
 
O

Otis Mukinfus

I am new to .Net and working on my first program. I have created a Data
Source using the Data Source Configuration Wizard, and an Access database.
However, when I distribute this app, I will not have control over where the
database resides. How can I programmatically change the connection string in
the data set created by the wizard?

Well, since you don't know where the user will have the database, you will need
to have them tell you where it is. You can do this by using the OpenFileDialog
to let them navigate to the file and choose it, but be aware that they may not
know how to do that.

The better way to do this is to add your database to the application's project
and let the distribution package put the database file in a location that is
always known to the application.

Search the documentation for "deployment". That will get you started. If you
don't understand what you find then you can zero in on the target by posting a
less general question.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 
R

RobinS

Will you at least know what network drive it's sitting on? If so, you could
put the network path in as the default
\\servername\share\mydrive\mydata.mdb

Otherwise, you're going to have to give them a dialog to go find the
database.
Then you can store the setting for the user in <Settings> and use it after
that.

The connection string is probably in your <Settings> area anyway. In VB2005,
double-click on MyProject to bring up the project properties. Then click on
the
Settings tab. Are they there? If so, you can change them after the user
selects a database.

Robin S.
 
C

Cor Ligthert [MVP]

Vernon,
The problem is that you don't tell what kind of database you use, in my idea
you got mostly all Jet (access) database answers.

However you can always change the connectionstring in your program for
another one.

www.connectionstrings.com

I hope this helps,

Cor
 
O

Otis Mukinfus

Vernon,
The problem is that you don't tell what kind of database you use, in my idea
you got mostly all Jet (access) database answers.

However you can always change the connectionstring in your program for
another one.

www.connectionstrings.com

I hope this helps,

Cor
[snip]

It *IS* an Access database. Perhaps you missed the line where he said it was an
Access database...
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top