Home All Groups Group Topic Archive Search About

Changing Data Source Location

Author
4 Dec 2006 10:58 PM
Vernon Peppers
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?

Author
5 Dec 2006 12:26 AM
Otis Mukinfus
On Mon, 4 Dec 2006 14:58:02 -0800, Vernon Peppers
<VernonPepp***@discussions.microsoft.com> wrote:

>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
Author
5 Dec 2006 2:14 AM
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.
---------------------------------------------
Show quote
"Vernon Peppers" <VernonPepp***@discussions.microsoft.com> wrote in message
news:5E892F1A-43B6-4105-8770-2C378406F7E7@microsoft.com...
>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?
Author
5 Dec 2006 10:29 PM
Vernon Peppers
Thanks Robin, that is just what I was looking for.  I had already put in the
File Open dialog, and stored the results in the Registry.  I juist didn't
know where to change the connection.

Show quote
"RobinS" wrote:

> 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.
> ---------------------------------------------
> "Vernon Peppers" <VernonPepp***@discussions.microsoft.com> wrote in message
> news:5E892F1A-43B6-4105-8770-2C378406F7E7@microsoft.com...
> >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?
>
>
>
Author
6 Dec 2006 8:16 PM
Vernon Peppers
Whoops, that wasn't as much help as I thought.  The connection string in the
settings is read-only.  Now I am back to where I started.

On a side note, how can I remove a data source once I create it?

Show quote
"RobinS" wrote:

> 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.
> ---------------------------------------------
> "Vernon Peppers" <VernonPepp***@discussions.microsoft.com> wrote in message
> news:5E892F1A-43B6-4105-8770-2C378406F7E7@microsoft.com...
> >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?
>
>
>
Author
7 Dec 2006 4:36 AM
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

Show quote
"Vernon Peppers" <VernonPepp***@discussions.microsoft.com> schreef in
bericht news:C25D98EE-D753-4922-A95F-7A25F0D7888A@microsoft.com...
> Whoops, that wasn't as much help as I thought.  The connection string in
> the
> settings is read-only.  Now I am back to where I started.
>
> On a side note, how can I remove a data source once I create it?
>
> "RobinS" wrote:
>
>> 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.
>> ---------------------------------------------
>> "Vernon Peppers" <VernonPepp***@discussions.microsoft.com> wrote in
>> message
>> news:5E892F1A-43B6-4105-8770-2C378406F7E7@microsoft.com...
>> >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?
>>
>>
>>
Author
7 Dec 2006 1:17 PM
Otis Mukinfus
On Thu, 7 Dec 2006 05:36:00 +0100, "Cor Ligthert [MVP]"
<notmyfirstn***@planet.nl> wrote:

Show quote
>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]
>>> "Vernon Peppers" <VernonPepp***@discussions.microsoft.com> wrote in
>>> message
>>> news:5E892F1A-43B6-4105-8770-2C378406F7E7@microsoft.com...
>>> >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?
>>>
>>>
>>>
>

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

AddThis Social Bookmark Button