Friday, April 4, 2014

SqlConnectionString in ASP.NET

Step 1 :  Add this to asp.net .cs page
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ValweaveFa"].ConnectionString);

Step 2 : Add below lines to web.conf

<connectionStrings>
<add name="ApplicationServices"
connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
providerName="MySql.Data.MySqlClient" />
<add name="ValweaveFa" connectionString="Data Source=ADMIN-PC\SQLEXPRESS;Initial Catalog=Valweave;Integrated Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

No comments:

Post a Comment