Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 27, 2013 03:06 PM by Laflak
0 Points
2 Posts
Jan 27, 2013 02:30 PM|LINK
Hi Experts,
I have develop a sample web application with gridview and sql server as db.
But i have an error in con.open() -- Instance Failure
web.config
<connectionStrings> <add name ="vel" connectionString="server=MURUGAVEL-PC\\SQLEXPRESS; database=Northwind; Integrated Security=True" /> </connectionStrings>
Test.cs
SqlConnection con = new SqlConnection(); SqlCommand cmd = new SqlCommand(); SqlDataReader dr; con.ConnectionString = ConfigurationManager.ConnectionStrings["vel"].ConnectionString; con.Open(); cmd.CommandText = "select * from Employees"; cmd.CommandType = CommandType.Text; cmd.Connection = con;
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
GridView1.DataSource = dr; GridView1.DataBind();
con.Close();
Plz help me out
Thanks Murugavel S
Member
28 Points
7 Posts
Jan 27, 2013 03:06 PM|LINK
There is a double slash \\ in your connection string declaration.
Remove it, this should work.
<connectionStrings> <add name ="vel" connectionString="server=MURUGAVEL-PC\SQLEXPRESS; database=Northwind; Integrated Security=True" /> </connectionStrings>
murugaveltrp
0 Points
2 Posts
Gridview
Jan 27, 2013 02:30 PM|LINK
Hi Experts,
I have develop a sample web application with gridview and sql server as db.
But i have an error in
con.open() -- Instance Failure
web.config
<connectionStrings>
<add name ="vel" connectionString="server=MURUGAVEL-PC\\SQLEXPRESS; database=Northwind; Integrated Security=True" />
</connectionStrings>
Test.cs
SqlConnection con = new SqlConnection();
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
con.ConnectionString = ConfigurationManager.ConnectionStrings["vel"].ConnectionString;
con.Open();
cmd.CommandText = "select * from Employees";
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
GridView1.DataSource = dr;
GridView1.DataBind();
con.Close();
Plz help me out
Thanks
Murugavel S
Laflak
Member
28 Points
7 Posts
Re: Gridview
Jan 27, 2013 03:06 PM|LINK
There is a double slash \\ in your connection string declaration.
Remove it, this should work.