The Exception is on the code The code is
string cs=ConfigurationManager.ConnectionStrings["Sam"].ConnectionString;
using(SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("Select * from tblProduct", con);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
GridView1.DataSource = rdr;
GridView1.DataBind();
}
So I have a one web-Config file.so I am connect with it. The code inside a web config is
<connectionStrings>
<add name ="Sam"
connectionString=" data source=.\\SQLExpress; database=sample; Integrated Security=true " />
</connectionStrings>
After Compiling it there is no error but when I debug it, at the run time I got
An exception of type 'System.InvalidOperationException' occurred in System.Data.dll but was not handled in user code. Additional information: Instance failure.
Why I am getting such error