Friday, December 24, 2004

Using Web.Config for getting connection string

[Note : replace "<" with < & ">" with >]

In web.config file

"<"appSettings">"

"<"add value="Initial Catalog=;Data Source=;UID=;password=" key="ConnectionString" ">"

"<"/add">"

"<"/appSettings">"

How to get the connection string in code [C#]

Import
System.Configuration namespace

string connectionString = ConfigurationSettings.AppSettings["ConnectionString"];

No comments: