Common SQL Connections in App.Config file
------------------------------------------------------
Both App.Config and Web.Config File:-
<configuration>
<connectionStrings><add name="TestConnectionString" connectionString="Data Source=192.168.0.7;Initial Catalog=Test;User Id=sa; pwd=test@123" providerName="System.Data.SqlClient"/></connectionStrings><appSettings><add key="DBString" value="Data Source=192.168.0.7; Initial Catalog=TEST; User Id=sa; pwd=test@123"/></appSettings>
</configuration>
In File(For App.Config)
``````````
SqlConnection sqlcon = new SqlConnection(ConfigurationSettings.AppSettings["DBString"])
In File(For Web.Config)
````````
SqlConnection sqlCon = new SqlConnection(ConfigurationManager.AppSettings["DBString"])
No comments:
Post a Comment