Saturday 30 April 2011

How To use Connection String From web.config

In Web.config
<configuration>
<connectionStrings>
          <add name="ConnectionStringName" connectionString="Data Source=SQLSERVER;Initial Catalog=DBNAME;User ID=ID;Password=PASS" providerName="System.Data.SqlClient"/>  </connectionStrings>
</configuration>

In DAL file
using System.Configuration;
static string connStr =ConfigurationManager.ConnectionStrings["ConnectionStringName"].ConnectionString;


No comments:

Post a Comment