Hi,
i am beginner for Dot Net and i don't know how to show a data from sql server in gridview.
Please give me solutions .
Thanks & Regards
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Narasimha Reddy ChennupalliPosted Jul 5, 2015, 1:09 AM
Small correction on your code snippet
SqlCommand cmd=new SqlCommand("select * from table_Name", con);
SqlDataAdapter da=new SqlDataAdapter(cmd,con);//Wrong
// here no need to give connection
SqlDataAdapter da=new SqlDataAdapter(cmd);// correct
// bcz you already mention the connection in cmd(object of Sql Command).
Rahul PrajapatPosted Jul 4, 2015, 7:49 PM
Dataset ds=new Dataset ();
da.fill(ds);
Gridview1.DataSource=ds;
Gridview1.DataBind();
con.Close();
Narasimha Reddy ChennupalliPosted Jul 4, 2015, 2:04 PM
String strConnection="";// connection string here
SqlConnection con=new SqlConnection(strConnection);
SqlCommand cmd=new SqlCommand("select * from EmpTable", con);
SqlDataAdapter da=new SqlDataAdapter(cmd);
Dataset ds=new Dataset ();
con.Open();
da.fill(ds);
Gridview1.DataSource=ds;
Gridview1.DataBound;
con.Close();
Munesh SharmaPosted Jul 1, 2015, 6:30 AM
Pankaj Kumar ChoudharyPosted Jul 1, 2015, 5:54 AM
how to get data from sql database to gridview by coding
C# DataGridView Binding - SQL S
how to display data from sql server in gridview - CodeProject
erver dataset
RakeshPosted Jul 1, 2015, 2:48 AM
Rajeesh MenothPosted Jul 1, 2015, 2:45 AM