Web.config File:
We can add conncetion string in web.config file for security reasons, in the following way:
<configuration>
<appSettings>
<add key="ConnectString" value="Server=servername;Database=databasename;uid=yourUserId;pwd=yourPassword"/>
Default.aspx.cs page:
Getting Connection String from web.config in c# program )(For example, Default.aspx.cs page_load event)
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectString Name"].ConnectionString);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment