Hi All,
I have to create a connection string which i can use in all the pages.I do not want to write connection strings codes in all the pages.
Please help
Connection String
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Jiteendra SampathiraoRank #585 · 4.1K reputationPosted Nov 19, 2010, 12:40 AM EST
Add namespace : System.configuration in code behind page In web.config file write this code under appsettings tag write And retrive the connection string using below code Public Shared Function getConnectionString() As String Return ConfigurationManager.AppSettings("sql") End Function write like this when creating a connectionstring: conn = New Mysqlconnection((getConnectionString()) conn.open ----------------------------------------------------------------------------------------------------------- If this post helped you, then tick the "Do you like this Answer" checkbox which is placed at above this post.Hirendra SisodiyaRank #258 · 9.8K reputationPosted Nov 22, 2010, 9:03 PM EST
thanks
CrishRank #1,487 · 1.1K reputationPosted Nov 30, 2010, 12:02 AM EST
To come out this issue you can create just one class.
In this class you can create one method of connection(with any name) and just pass the connection string .
then you can call this method in every pages in page load event .. so there is no need to create a connection string which you can use in all the pages.
You should pass connection string only one time and use it in every pages using call that method.
Also you can set connection string in web.config file.