Hai,I am trying to connection using web.confing in connectionstring element
and i have written below code in connectionstring element in

<connectionStrings>
      <add name="DB1" connectionString="Data Source=DEV5\\SQLEXPRESS;Initial Catalog=icondatabase;Integrated Security=True" />
      </connectionStrings>

And in the .aspx.cs file (in Load_page)i have written below code

string connection= ConfigurationManager.ConnectionStrings["DB1"].ToString();
      SqlConnection cn = new SqlConnection("connection");

while i compiled page it give the error:
"
ArgumentExeption was Unhandled by User Code
Format of the initialization string does not conform to specification starting at index 0."

any body plz help me......

Recommended Answers

All 2 Replies

Remove double quotes.

...
 SqlConnection cn = new SqlConnection(connection);

Remove double quotes.

...
 SqlConnection cn = new SqlConnection(connection);

thanks it run....successfully.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.