Dear Experts,

I am new in asp.net.
I have to make a website in asp within 5 months. I have written connection string for sql server 2008 R2.
I want to use "default login" but my connection string does not work.

   <add name="donationConnectionString" connectionString="Data Source=COMPAQ-PC\SQLEXPRESS;Initial Catalog=donation;Integrated Security=True"
   providerName="System.Data.SqlClient" />

And I have created connection on every page. But my connection is not created.

using system.data.sqlclient;

sqlconnection con = new sqlconnection("Data Source=$$$$; Initial Catalog = $$$$$; Integrated Security=true");


I need your help. . . .

5 Years
Discussion Span
Last Post by hericles

If you add a connection string to the web.config and intend to use it, you access it with this:

sqlConnection con = new sqlConnection(ConfigurationManager.ConnectionString["donationConnectionString"]);

You will need to add System.Configuration to your using statements at the top of the class for this to work. The configurationManager will then go to the web.config file and get the connection string named "donationConnectionString".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.