PC Review


Reply
Thread Tools Rate Thread

C# ConnectionStringName

 
 
jp2msft
Guest
Posts: n/a
 
      21st Jan 2008
Using VB, I can access the database connection string (or other application
settings) using:

Dim myconnStr As String = My.Settings.ConnectionStringName

What is the equivalent in C#?

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      21st Jan 2008
ConfigurationManager.ConnectionStrings["{Connection String Name}"]


--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
"jp2msft" <(E-Mail Removed)> wrote in message
news:8EB08518-B154-4DE6-ACEF-(E-Mail Removed)...
> Using VB, I can access the database connection string (or other
> application
> settings) using:
>
> Dim myconnStr As String = My.Settings.ConnectionStringName
>
> What is the equivalent in C#?
>



 
Reply With Quote
 
jp2msft
Guest
Posts: n/a
 
      23rd Jan 2008
Some things from VB to C# just aren't as simple as you'd think!

I kept looking for something under the "this" keyword.

Thanks, Cowboy!

"Cowboy (Gregory A. Beamer)" wrote:

> ConfigurationManager.ConnectionStrings["{Connection String Name}"]
>
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> *************************************************
> | Think outside the box!
> |
> *************************************************
> "jp2msft" <(E-Mail Removed)> wrote in message
> news:8EB08518-B154-4DE6-ACEF-(E-Mail Removed)...
> > Using VB, I can access the database connection string (or other
> > application
> > settings) using:
> >
> > Dim myconnStr As String = My.Settings.ConnectionStringName
> >
> > What is the equivalent in C#?
> >

>
>
>

 
Reply With Quote
 
jp2msft
Guest
Posts: n/a
 
      23rd Jan 2008
Wasn't able to get my system to recognize 'ConfigurationManager'. In the
Help, I saw it was part of System.Configuration, but it still did not appear
even after adding "#using System.Configuration;".

How are you getting this?

"Cowboy (Gregory A. Beamer)" wrote:

> ConfigurationManager.ConnectionStrings["{Connection String Name}"]
>
>
> --
> Gregory A. Beamer
> MVP, MCP: +I, SE, SD, DBA
>
> *************************************************
> | Think outside the box!
> |
> *************************************************
> "jp2msft" <(E-Mail Removed)> wrote in message
> news:8EB08518-B154-4DE6-ACEF-(E-Mail Removed)...
> > Using VB, I can access the database connection string (or other
> > application
> > settings) using:
> >
> > Dim myconnStr As String = My.Settings.ConnectionStringName
> >
> > What is the equivalent in C#?
> >

>
>
>

 
Reply With Quote
 
Bill McCarthy
Guest
Posts: n/a
 
      23rd Jan 2008
Try Settings.Default.ConnectionStringName

"jp2msft" <(E-Mail Removed)> wrote in message
news:65282AB5-1691-4F74-A8E4-(E-Mail Removed)...
> Wasn't able to get my system to recognize 'ConfigurationManager'. In the
> Help, I saw it was part of System.Configuration, but it still did not
> appear
> even after adding "#using System.Configuration;".
>
> How are you getting this?
>
> "Cowboy (Gregory A. Beamer)" wrote:
>
>> ConfigurationManager.ConnectionStrings["{Connection String Name}"]
>>
>>
>> --
>> Gregory A. Beamer
>> MVP, MCP: +I, SE, SD, DBA
>>
>> *************************************************
>> | Think outside the box!
>> |
>> *************************************************
>> "jp2msft" <(E-Mail Removed)> wrote in message
>> news:8EB08518-B154-4DE6-ACEF-(E-Mail Removed)...
>> > Using VB, I can access the database connection string (or other
>> > application
>> > settings) using:
>> >
>> > Dim myconnStr As String = My.Settings.ConnectionStringName
>> >
>> > What is the equivalent in C#?
>> >

>>
>>
>>


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      24th Jan 2008
Hi,

Normally:
ConfigurationSettings.AppSettings["TheNameOfTheString"];

Be aware that the "my" class is only an extra shared class (static in C#) in
VB for Net that is created to make it easier for old VB6 users to go to VB
for Net.

The code above with the difference of the brackets can as well be used in VB
for Net.

Cor


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
connectionStringName for RoleProvider Chris Microsoft ASP .NET 0 6th Mar 2006 12:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:28 AM.