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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Posted Sep 26, 2010, 10:22 PM EDT
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....
karthick kumar106 reputationPosted Sep 26, 2010, 10:59 PM EDT
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..