Hi,
I'm creating an application that has to connect sequentially to different
tadabases.

I added all the connection strings to app.config and I'm itterating through
them in the following manner:
foreach (ConnectionStringSettings connStringSettings in
ConfigurationManager.ConnectionStrings)
{
........
connection = new SqlConnection(connStringSettings.ConnectionString);
.........
}

and I get:
connStringSettings.ConnectionString =
"data source=.\\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"

which is completly different from what I have in my connection string. I
don't even know where this values is comming from.

But if I do
ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()

I get the correct values from app.config.

Where is the \\SQLEXPRESS connections string comming from and how can I
itterativly get the correct connection string values?

Thanks

Re: Connection Strings by Cor

Cor
Sat Jun 10 01:02:00 CDT 2006

Vi,

Are you using C++ in the VS2002 version or something else, without knowing
this it is helping with finding a needle in a meadow?

Cor

"Vi" <Vi@discussions.microsoft.com> schreef in bericht
news:EDFBA4AF-0F89-400B-9F3D-4D8069649954@microsoft.com...
> Hi,
> I'm creating an application that has to connect sequentially to different
> tadabases.
>
> I added all the connection strings to app.config and I'm itterating
> through
> them in the following manner:
> foreach (ConnectionStringSettings connStringSettings in
> ConfigurationManager.ConnectionStrings)
> {
> ........
> connection = new SqlConnection(connStringSettings.ConnectionString);
> .........
> }
>
> and I get:
> connStringSettings.ConnectionString =
> "data source=.\\SQLEXPRESS;Integrated
> Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
> Instance=true"
>
> which is completly different from what I have in my connection string. I
> don't even know where this values is comming from.
>
> But if I do
> ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
> ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()
>
> I get the correct values from app.config.
>
> Where is the \\SQLEXPRESS connections string comming from and how can I
> itterativly get the correct connection string values?
>
> Thanks



Re: Connection Strings by Vi

Vi
Sat Jun 10 07:40:01 CDT 2006

I'm using C# and VS.NET2005
When I'm doing
ConfigurationManager.ConnectionStrings)
{
........
connection = new SqlConnection(connStringSettings.ConnectionString);
.........
}
the first itteration has connStringSettings.ConnectionString = "data
source=.\\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true"

, which I don't know where it is comming from.

The itteration 2 and 3 have the expected values that I inserted in app.config.
Thanks


"Cor Ligthert [MVP]" wrote:

> Vi,
>
> Are you using C++ in the VS2002 version or something else, without knowing
> this it is helping with finding a needle in a meadow?
>
> Cor
>
> "Vi" <Vi@discussions.microsoft.com> schreef in bericht
> news:EDFBA4AF-0F89-400B-9F3D-4D8069649954@microsoft.com...
> > Hi,
> > I'm creating an application that has to connect sequentially to different
> > tadabases.
> >
> > I added all the connection strings to app.config and I'm itterating
> > through
> > them in the following manner:
> > foreach (ConnectionStringSettings connStringSettings in
> > ConfigurationManager.ConnectionStrings)
> > {
> > ........
> > connection = new SqlConnection(connStringSettings.ConnectionString);
> > .........
> > }
> >
> > and I get:
> > connStringSettings.ConnectionString =
> > "data source=.\\SQLEXPRESS;Integrated
> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
> > Instance=true"
> >
> > which is completly different from what I have in my connection string. I
> > don't even know where this values is comming from.
> >
> > But if I do
> > ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
> > ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()
> >
> > I get the correct values from app.config.
> >
> > Where is the \\SQLEXPRESS connections string comming from and how can I
> > itterativly get the correct connection string values?
> >
> > Thanks
>
>
>

Re: Connection Strings by Vi

Vi
Sat Jun 10 11:20:02 CDT 2006

no, this is a Windows Forms app, but ultimatly will be a Windows Service.
Thanks

"Miha Markic [MVP C#]" wrote:

> Are you doing asp.net?
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
> "Vi" <Vi@discussions.microsoft.com> wrote in message
> news:F1C1712D-57E3-4472-8BE4-5D4FF9EF984F@microsoft.com...
> > I'm using C# and VS.NET2005
> > When I'm doing
> > ConfigurationManager.ConnectionStrings)
> > {
> > ........
> > connection = new SqlConnection(connStringSettings.ConnectionString);
> > .........
> > }
> > the first itteration has connStringSettings.ConnectionString = "data
> > source=.\\SQLEXPRESS;Integrated
> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
> > Instance=true"
> >
> > , which I don't know where it is comming from.
> >
> > The itteration 2 and 3 have the expected values that I inserted in
> > app.config.
> > Thanks
> >
> >
> > "Cor Ligthert [MVP]" wrote:
> >
> >> Vi,
> >>
> >> Are you using C++ in the VS2002 version or something else, without
> >> knowing
> >> this it is helping with finding a needle in a meadow?
> >>
> >> Cor
> >>
> >> "Vi" <Vi@discussions.microsoft.com> schreef in bericht
> >> news:EDFBA4AF-0F89-400B-9F3D-4D8069649954@microsoft.com...
> >> > Hi,
> >> > I'm creating an application that has to connect sequentially to
> >> > different
> >> > tadabases.
> >> >
> >> > I added all the connection strings to app.config and I'm itterating
> >> > through
> >> > them in the following manner:
> >> > foreach (ConnectionStringSettings connStringSettings in
> >> > ConfigurationManager.ConnectionStrings)
> >> > {
> >> > ........
> >> > connection = new SqlConnection(connStringSettings.ConnectionString);
> >> > .........
> >> > }
> >> >
> >> > and I get:
> >> > connStringSettings.ConnectionString =
> >> > "data source=.\\SQLEXPRESS;Integrated
> >> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
> >> > Instance=true"
> >> >
> >> > which is completly different from what I have in my connection string.
> >> > I
> >> > don't even know where this values is comming from.
> >> >
> >> > But if I do
> >> > ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
> >> > ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()
> >> >
> >> > I get the correct values from app.config.
> >> >
> >> > Where is the \\SQLEXPRESS connections string comming from and how can I
> >> > itterativly get the correct connection string values?
> >> >
> >> > Thanks
> >>
> >>
> >>
>
>
>

Re: Connection Strings by Miha

Miha
Sat Jun 10 12:57:06 CDT 2006

Yes, I see.
I guess that this entry serves to aspnet applications for default database
when one is needed.
I would suggest you to ignore the entry
(connStringSettings.Name=="LocalSqlServer).

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:BB7F4F85-431D-46A7-BF9B-1FEEC38EFEE1@microsoft.com...
> no, this is a Windows Forms app, but ultimatly will be a Windows Service.
> Thanks
>
> "Miha Markic [MVP C#]" wrote:
>
>> Are you doing asp.net?
>>
>> --
>> Miha Markic [MVP C#]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>
>> "Vi" <Vi@discussions.microsoft.com> wrote in message
>> news:F1C1712D-57E3-4472-8BE4-5D4FF9EF984F@microsoft.com...
>> > I'm using C# and VS.NET2005
>> > When I'm doing
>> > ConfigurationManager.ConnectionStrings)
>> > {
>> > ........
>> > connection = new SqlConnection(connStringSettings.ConnectionString);
>> > .........
>> > }
>> > the first itteration has connStringSettings.ConnectionString = "data
>> > source=.\\SQLEXPRESS;Integrated
>> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
>> > Instance=true"
>> >
>> > , which I don't know where it is comming from.
>> >
>> > The itteration 2 and 3 have the expected values that I inserted in
>> > app.config.
>> > Thanks
>> >
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >> Vi,
>> >>
>> >> Are you using C++ in the VS2002 version or something else, without
>> >> knowing
>> >> this it is helping with finding a needle in a meadow?
>> >>
>> >> Cor
>> >>
>> >> "Vi" <Vi@discussions.microsoft.com> schreef in bericht
>> >> news:EDFBA4AF-0F89-400B-9F3D-4D8069649954@microsoft.com...
>> >> > Hi,
>> >> > I'm creating an application that has to connect sequentially to
>> >> > different
>> >> > tadabases.
>> >> >
>> >> > I added all the connection strings to app.config and I'm itterating
>> >> > through
>> >> > them in the following manner:
>> >> > foreach (ConnectionStringSettings connStringSettings in
>> >> > ConfigurationManager.ConnectionStrings)
>> >> > {
>> >> > ........
>> >> > connection = new
>> >> > SqlConnection(connStringSettings.ConnectionString);
>> >> > .........
>> >> > }
>> >> >
>> >> > and I get:
>> >> > connStringSettings.ConnectionString =
>> >> > "data source=.\\SQLEXPRESS;Integrated
>> >> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
>> >> > Instance=true"
>> >> >
>> >> > which is completly different from what I have in my connection
>> >> > string.
>> >> > I
>> >> > don't even know where this values is comming from.
>> >> >
>> >> > But if I do
>> >> > ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
>> >> > ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()
>> >> >
>> >> > I get the correct values from app.config.
>> >> >
>> >> > Where is the \\SQLEXPRESS connections string comming from and how
>> >> > can I
>> >> > itterativly get the correct connection string values?
>> >> >
>> >> > Thanks
>> >>
>> >>
>> >>
>>
>>
>>



Re: Connection Strings by Cor

Cor
Sun Jun 11 00:29:55 CDT 2006

Vi,

This is in 2005 a normal description of a connectionstring

<connectionStrings>
<add
name="WindowsApplicationCSharp.Properties.Settings.NorthwindConnectionString"
connectionString="Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\test1\Northwind.mdb"
providerName="System.Data.OleDb" />
</connectionStrings>

This is connected in the datasource by the synstax

\\\
this._connection = new System.Data.OleDb.OleDbConnection();
this._connection.ConnectionString =
global::TheTestApp.Properties.Settings.Default.NorthwindConnectionString;
///

Afaik can you make as much connectionstrings as you want and overrule those
in your program as much as you want by those created.

I hope this helps,

Cor

"Vi" <Vi@discussions.microsoft.com> schreef in bericht
news:F1C1712D-57E3-4472-8BE4-5D4FF9EF984F@microsoft.com...
> I'm using C# and VS.NET2005
> When I'm doing
> ConfigurationManager.ConnectionStrings)
> {
> ........
> connection = new SqlConnection(connStringSettings.ConnectionString);
> .........
> }
> the first itteration has connStringSettings.ConnectionString = "data
> source=.\\SQLEXPRESS;Integrated
> Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
> Instance=true"
>
> , which I don't know where it is comming from.
>
> The itteration 2 and 3 have the expected values that I inserted in
> app.config.
> Thanks
>
>
> "Cor Ligthert [MVP]" wrote:
>
>> Vi,
>>
>> Are you using C++ in the VS2002 version or something else, without
>> knowing
>> this it is helping with finding a needle in a meadow?
>>
>> Cor
>>
>> "Vi" <Vi@discussions.microsoft.com> schreef in bericht
>> news:EDFBA4AF-0F89-400B-9F3D-4D8069649954@microsoft.com...
>> > Hi,
>> > I'm creating an application that has to connect sequentially to
>> > different
>> > tadabases.
>> >
>> > I added all the connection strings to app.config and I'm itterating
>> > through
>> > them in the following manner:
>> > foreach (ConnectionStringSettings connStringSettings in
>> > ConfigurationManager.ConnectionStrings)
>> > {
>> > ........
>> > connection = new SqlConnection(connStringSettings.ConnectionString);
>> > .........
>> > }
>> >
>> > and I get:
>> > connStringSettings.ConnectionString =
>> > "data source=.\\SQLEXPRESS;Integrated
>> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
>> > Instance=true"
>> >
>> > which is completly different from what I have in my connection string.
>> > I
>> > don't even know where this values is comming from.
>> >
>> > But if I do
>> > ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
>> > ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()
>> >
>> > I get the correct values from app.config.
>> >
>> > Where is the \\SQLEXPRESS connections string comming from and how can I
>> > itterativly get the correct connection string values?
>> >
>> > Thanks
>>
>>
>>



Re: Connection Strings by Miha

Miha
Sun Jun 11 03:04:56 CDT 2006

Or insert <clear/> node when appropriate:
<connectionStrings>

<clear />

</connectionStrings>

This sample will yield no connection strings at all.


--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:BB7F4F85-431D-46A7-BF9B-1FEEC38EFEE1@microsoft.com...
> no, this is a Windows Forms app, but ultimatly will be a Windows Service.
> Thanks
>
> "Miha Markic [MVP C#]" wrote:
>
>> Are you doing asp.net?
>>
>> --
>> Miha Markic [MVP C#]
>> RightHand .NET consulting & development www.rthand.com
>> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>>
>> "Vi" <Vi@discussions.microsoft.com> wrote in message
>> news:F1C1712D-57E3-4472-8BE4-5D4FF9EF984F@microsoft.com...
>> > I'm using C# and VS.NET2005
>> > When I'm doing
>> > ConfigurationManager.ConnectionStrings)
>> > {
>> > ........
>> > connection = new SqlConnection(connStringSettings.ConnectionString);
>> > .........
>> > }
>> > the first itteration has connStringSettings.ConnectionString = "data
>> > source=.\\SQLEXPRESS;Integrated
>> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
>> > Instance=true"
>> >
>> > , which I don't know where it is comming from.
>> >
>> > The itteration 2 and 3 have the expected values that I inserted in
>> > app.config.
>> > Thanks
>> >
>> >
>> > "Cor Ligthert [MVP]" wrote:
>> >
>> >> Vi,
>> >>
>> >> Are you using C++ in the VS2002 version or something else, without
>> >> knowing
>> >> this it is helping with finding a needle in a meadow?
>> >>
>> >> Cor
>> >>
>> >> "Vi" <Vi@discussions.microsoft.com> schreef in bericht
>> >> news:EDFBA4AF-0F89-400B-9F3D-4D8069649954@microsoft.com...
>> >> > Hi,
>> >> > I'm creating an application that has to connect sequentially to
>> >> > different
>> >> > tadabases.
>> >> >
>> >> > I added all the connection strings to app.config and I'm itterating
>> >> > through
>> >> > them in the following manner:
>> >> > foreach (ConnectionStringSettings connStringSettings in
>> >> > ConfigurationManager.ConnectionStrings)
>> >> > {
>> >> > ........
>> >> > connection = new
>> >> > SqlConnection(connStringSettings.ConnectionString);
>> >> > .........
>> >> > }
>> >> >
>> >> > and I get:
>> >> > connStringSettings.ConnectionString =
>> >> > "data source=.\\SQLEXPRESS;Integrated
>> >> > Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User
>> >> > Instance=true"
>> >> >
>> >> > which is completly different from what I have in my connection
>> >> > string.
>> >> > I
>> >> > don't even know where this values is comming from.
>> >> >
>> >> > But if I do
>> >> > ConfigurationManager.ConnectionStrings["MyConnString1"].ToString(),
>> >> > ConfigurationManager.ConnectionStrings["MyConnString2"].ToString()
>> >> >
>> >> > I get the correct values from app.config.
>> >> >
>> >> > Where is the \\SQLEXPRESS connections string comming from and how
>> >> > can I
>> >> > itterativly get the correct connection string values?
>> >> >
>> >> > Thanks
>> >>
>> >>
>> >>
>>
>>
>>