Hello John,
To get that string try:
// Get the connectionString.
ConnectionStringSettings connectionStringSettings =
ConfigurationManager.ConnectionStrings["GUIDBConnectionString"];
Then to use it:
// Initialize the connection with the string
SqlConnection sqlConnection - new
SqlConnection(connectionStringSettings.ConnectionString);

Signature
I think that should do it - brians
http://www.limbertech.com
> If a SQLDataSource add the following to my web.config file, how to I
> programmatically extract the connection string:
[quoted text clipped - 11 lines]
>
> </connectionStrings>
brians[MCSD] - 16 Feb 2006 00:49 GMT
Sorry, I am very much in the mindset of ASP.NET 2.0. they have added some
nice additional configuration management features. For 1.1 try:
web.config:
<appSettings>
<add key="ConnectionString" value="server=...;database=...;user id=...;
password=...;" />
</appSettings>
In your connection code:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);

Signature
brians
http://www.limbertech.com
> Hello John,
>
[quoted text clipped - 24 lines]
> >
> > </connectionStrings>
rabram66@yahoo.com - 26 Feb 2006 13:26 GMT
I tried to use:
SqlConnection conn = new
SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"])
in my connection code, but I got the error message below.
'Public Shared ReadOnly Property AppSettings() As
System.Collections.Specialized.NameValueCollection' is obsolete: 'This
method is obsolete, it has been replaced by
System.Configuration!System.Configuration.ConfigurationManager.AppSettings'
Is there something I should be doing differently in asp.net 2.0?
Juan T. Llibre - 26 Feb 2006 16:57 GMT
I have found it easier to give up altogether on appSettings,
and use connectionStrings instead, although you can use either.
For VB and C# examples, see :
http://www.asp.net/QuickStart/aspnet/doc/management/retrieve.aspx
Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
>I tried to use:
> SqlConnection conn = new
[quoted text clipped - 7 lines]
>
> Is there something I should be doing differently in asp.net 2.0?
John A Grandy - 16 Feb 2006 02:08 GMT
Yes. I am doing 2.0 , so this is what I want. Thanks.
> Hello John,
>
[quoted text clipped - 24 lines]
>>
>> </connectionStrings>
rabram66@yahoo.com - 26 Feb 2006 13:22 GMT
> Yes. I am doing 2.0 , so this is what I want. Thanks.
>
[quoted text clipped - 30 lines]
> >>
> >> </connectionStrings>
Here is what works for me;
--->In your WEB.CONFIG file
<appSettings>
<add key="DBConn" value="Provider=Microsoft.Jet.OLEDB.4.0; Data
Source=c:\inetpub\wwwroot\data\test.mdb" />
</appSettings>
-->In your page
Dim objConn As OleDBConnection = New
OleDBConnection(ConfigurationSettings.AppSettings("DBConn"))
Hope this helps,
Jeremy Reid
http://blackstaronline.net/hgtit