mr. kumar the answer you ve given is ok but u used connected environment to update the table...i wanted to update table through dataset on grid as well as on table.
Loading
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.
karthick kumarPosted Sep 27, 2010, 2:59 AM
try out this.
try
{
SqlConnection con = new SqlConnection("data source=.\\sqlexpress;integrated security=true;initial catalog=student");
con.Open();
SqlCommand cmd = new SqlCommand("update employee set name='croco' where id='7'",con);
cmd.ExecuteNonQuery();
SqlDataAdapter da = new SqlDataAdapter("select * from employee", con);
DataSet ds = new DataSet();
da.Fill(ds, "employee");
dataGrid1.DataSource = ds;
con.Close();
}
catch (Exception ex)
{
}
if my answer is correct , please mark it as correct answer..
Posted Sep 27, 2010, 2:22 AM
String strconnect="data source=.\\sqlexpress;integrated security=true;initial catalog=student";
string strselect="select * from employee";
try
{
sqlconnection con=new sqlconnection(strconnect);
con.open();
sqlcommand cmd=new SqlCommand("update employee set name='croco' where id='7'")
cmd.ExecuteNonquery();
sqldataadapter da=new sqldataadapter(strselect,con);
Dataset ds=new Dataset();
Datatable dt=new Datatable();
da.Fill(ds,"employee")
dt=da.Tables["employee"]
dataGrid1.Datasource=dt;
con.close();
}
Hope this helps....
With Regards
P.Krishna Prasad
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If someway my answer helped u.... don't forget to mark it as correct answer....