Click here to Skip to main content
15,888,401 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to Generate Folder? Pin
Ravi Bhavnani13-Aug-12 7:18
professionalRavi Bhavnani13-Aug-12 7:18 
Questionview MS Word from web Pin
Jassim Rahma13-Aug-12 5:05
Jassim Rahma13-Aug-12 5:05 
QuestionRe: view MS Word from web Pin
Eddy Vluggen13-Aug-12 5:22
professionalEddy Vluggen13-Aug-12 5:22 
AnswerRe: view MS Word from web Pin
Jassim Rahma13-Aug-12 9:18
Jassim Rahma13-Aug-12 9:18 
AnswerRe: view MS Word from web Pin
Eddy Vluggen13-Aug-12 9:23
professionalEddy Vluggen13-Aug-12 9:23 
GeneralRe: view MS Word from web Pin
Jassim Rahma13-Aug-12 10:10
Jassim Rahma13-Aug-12 10:10 
NewsRe: view MS Word from web Pin
Eddy Vluggen13-Aug-12 11:39
professionalEddy Vluggen13-Aug-12 11:39 
AnswerRe: view MS Word from web Pin
Vijay Selvaraj26-Aug-12 22:07
Vijay Selvaraj26-Aug-12 22:07 
Questioncreate a new process at runtime Pin
George Nistor13-Aug-12 4:54
George Nistor13-Aug-12 4:54 
AnswerRe: create a new process at runtime Pin
Wes Aday13-Aug-12 5:17
professionalWes Aday13-Aug-12 5:17 
AnswerRe: create a new process at runtime Pin
Eddy Vluggen13-Aug-12 5:20
professionalEddy Vluggen13-Aug-12 5:20 
AnswerRe: create a new process at runtime Pin
Dave Kreskowiak13-Aug-12 5:22
mveDave Kreskowiak13-Aug-12 5:22 
GeneralRe: create a new process at runtime Pin
George Nistor13-Aug-12 5:27
George Nistor13-Aug-12 5:27 
GeneralRe: create a new process at runtime Pin
Dave Kreskowiak13-Aug-12 17:08
mveDave Kreskowiak13-Aug-12 17:08 
QuestionDeclaring a connection string in class file Pin
Member 925960613-Aug-12 3:21
Member 925960613-Aug-12 3:21 
AnswerRe: Declaring a connection string in class file Pin
Wes Aday13-Aug-12 3:27
professionalWes Aday13-Aug-12 3:27 
GeneralRe: Declaring a connection string in class file Pin
Pete O'Hanlon13-Aug-12 4:06
mvePete O'Hanlon13-Aug-12 4:06 
GeneralRe: Declaring a connection string in class file Pin
Wes Aday13-Aug-12 4:39
professionalWes Aday13-Aug-12 4:39 
GeneralRe: Declaring a connection string in class file Pin
Member 925960613-Aug-12 18:43
Member 925960613-Aug-12 18:43 
GeneralRe: Declaring a connection string in class file Pin
Pete O'Hanlon13-Aug-12 22:51
mvePete O'Hanlon13-Aug-12 22:51 
GeneralRe: Declaring a connection string in class file Pin
Member 925960614-Aug-12 0:00
Member 925960614-Aug-12 0:00 
GeneralRe: Declaring a connection string in class file Pin
Pete O'Hanlon14-Aug-12 0:04
mvePete O'Hanlon14-Aug-12 0:04 
AnswerRe: Declaring a connection string in class file Pin
Shameel13-Aug-12 4:23
professionalShameel13-Aug-12 4:23 
AnswerRe: Declaring a connection string in class file Pin
Pete O'Hanlon13-Aug-12 4:31
mvePete O'Hanlon13-Aug-12 4:31 
A connection string is just a string that conforms to a particular pattern. The actual value that goes into the string depends on how the database is set up (e.g. is it accessed Windows Authentication) and other features such as whether or not you want Multiple Active RecordSets (MARS), which allows you to perform several reads using what appears to be the same connection. A good list of connection strings is available here[^]

It's traditional to store the connection string inside the .config file. There is a ConnectionStrings section (you won't see it in the default .config file, as you have to add it). Inside this ConnectionStrings section, you will add a ConnectionString entry that holds the details of the connection itself.

To retrieve the connection string in your code, you just need to use the following (here I'm assuming you've added your connection string into the config file with a key of MyConnectionString):
C#
string connectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: Declaring a connection string in class file Pin
Shameel13-Aug-12 5:47
professionalShameel13-Aug-12 5:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.