|
|
|
start date: Sun, 29 Jul 2007 03:38:02 -0700,
posted on: microsoft.public.dotnet.framework.adonet
back
| Thread Index |
|
1
Luc
|
|
2
Miha Markic miha at rthand com
|
|
3
Sheng Jiang[MVP] uss
|
|
4
Miha Markic miha at rthand com
|
|
5
Sheng Jiang[MVP] uss
|
|
6
Saulo J. S. Machado
|
Change connectionstring Typed dataset
Hi,
I've noticed that if I change my connectionstring in the app.config file,
this isn't enough, a second change in the Global.System.Configuration is
necesary!!!
This means that after deployment and if the SQL server is changed, changing
the code is necesary, ..............?.??
can I prevent this?? HOW???
Thx
--
Best regards
Luc N
Date:Sun, 29 Jul 2007 03:38:02 -0700
Author:
|
Re: Change connectionstring Typed dataset
When you deploy the properly configured app.config (or better,
ASSEMBLYNAME.config) is enough.
When developing, though, the correct way is to change the value in
Project/Settings configuration.
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Luc" wrote in message
news:65260708-0124-4BAE-AAA3-FBD9D2F517E9@microsoft.com...
> Hi,
>
> I've noticed that if I change my connectionstring in the app.config file,
> this isn't enough, a second change in the Global.System.Configuration is
> necesary!!!
>
> This means that after deployment and if the SQL server is changed,
> changing
> the code is necesary, ..............?.??
>
> can I prevent this?? HOW???
>
> Thx
>
> --
> Best regards
> Luc N
Date:Sun, 29 Jul 2007 20:56:19 +0200
Author:
|
Re: Change connectionstring Typed dataset
You can handle the SettingsLoaded event to set the connection string setting
at runtime
void Settings_SettingsLoaded(object sender, SettingsLoadedEventArgs e)
{
this["ConnectionString"] = GetConnectionString();
}
--
Sheng Jiang
Microsoft MVP in VC++
"Luc" wrote in message
news:65260708-0124-4BAE-AAA3-FBD9D2F517E9@microsoft.com...
> Hi,
>
> I've noticed that if I change my connectionstring in the app.config file,
> this isn't enough, a second change in the Global.System.Configuration is
> necesary!!!
>
> This means that after deployment and if the SQL server is changed,
changing
> the code is necesary, ..............?.??
>
> can I prevent this?? HOW???
>
> Thx
>
> --
> Best regards
> Luc N
Date:Mon, 30 Jul 2007 14:17:57 -0500
Author:
|
Re: Change connectionstring Typed dataset
What's the point of settings then :-)
--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
"Sheng Jiang[MVP]" <sheng_jiang@hotmail.com.discuss> wrote in message
news:%23g5sU5t0HHA.3536@TK2MSFTNGP06.phx.gbl...
> You can handle the SettingsLoaded event to set the connection string
> setting
> at runtime
> void Settings_SettingsLoaded(object sender, SettingsLoadedEventArgs e)
> {
> this["ConnectionString"] = GetConnectionString();
> }
>
> --
> Sheng Jiang
> Microsoft MVP in VC++
Date:Mon, 30 Jul 2007 22:29:34 +0200
Author:
|
Re: Change connectionstring Typed dataset
To make the dataset designer happy...
--
Sheng Jiang
Microsoft MVP in VC++
"Miha Markic" <miha at rthand com> wrote in message
news:eJkv1hu0HHA.5152@TK2MSFTNGP02.phx.gbl...
> What's the point of settings then :-)
>
> --
> Miha Markic [MVP C#, INETA Country Leader for Slovenia]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "Sheng Jiang[MVP]" <sheng_jiang@hotmail.com.discuss> wrote in message
> news:%23g5sU5t0HHA.3536@TK2MSFTNGP06.phx.gbl...
> > You can handle the SettingsLoaded event to set the connection string
> > setting
> > at runtime
> > void Settings_SettingsLoaded(object sender, SettingsLoadedEventArgs e)
> > {
> > this["ConnectionString"] = GetConnectionString();
> > }
> >
> > --
> > Sheng Jiang
> > Microsoft MVP in VC++
>
Date:Mon, 30 Jul 2007 16:23:18 -0500
Author:
|
typed dataset - change connection string after
compilation
My development team faced this problem in the last week when we were developing some distributed system.
One choice your have is to:
1 - Eliminate the connectionstring from "Settings" of the typed datasets;
2 - Add the System.Configuration reference to the typed dataset project
3 - Go to each typed dataset Designer.vb file and REPLACE the statement:
"Me._connection.ConnectionString = Global..."
for this one:
Me._connection.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("CONNECTION")"
4 - Now your datasets should look for this tag, in the app.config XML file.
5 - If you don't provide the DAL.appconfig.xml file, the typed datasets will look for the Application.appconfig.xml and ... in this XML file you must add the tag:
....
</configSections>
<appSettings>
<add key ="CONNECTION" value ="connection string comes here"/>
</appSettings>
<connectionStrings>
....
See that it comes between configsections and appSettings.
6 - Now if you have the appconfig.xml for the application, you can benefit from taking the connectionstring from this file, instead of having it compiled into the DAL.dll. You can change the connection string in the xml file and see the changes in the connection.
For now, this is the only solution we have achieved for this problem.
EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
Date:Thu, 02 Aug 2007 05:40:28 -0700
Author:
|
|
|