Categories
Asp, Asp.net

Format of the initialization string does not conform to specification starting at index 0

Format of the initialization string does not conform to specification starting at index 0

Recently i am working on a project and came to this error: Format of the initialization string does not conform to specification starting at index 0. I looked on my code and i got to know that i have done a mistake on sqlconnection declaration.

Earlier we had discussed An item placeholder must be specified on ListView ‘DataList1’. Specify an item placeholder by setting a control’s ID property to “itemPlaceholder”. The item placeholder control must also specify runat=”server”Could not load file or assembly ‘System.EnterpriseServices’ or one of its dependencies. An attempt was made to load a program with an incorrect format.

Error:

Format of the initialization string does not conform to specification starting at index 0

I have highlighted error on above image, then i have changed from conn to strcon and it works like a charm. My code is like this.

String strconn = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
 protected void Page_Load(object sender, EventArgs e)
 {
 }
 protected void btn_cat_add_Click(object sender, EventArgs e)
 {
 // SqlConnection con = new SqlConnection(conn);
 // i have changed conn to strconn and it works fine.
 SqlConnection con = new SqlConnection(strconn);
 
 }