hopera

hopera

  • NA
  • 4
  • 0

Dataset update doesn't work

Apr 20 2004 4:33 AM
Hi to all ..... I have a problem on this code: this is sistattically correct but doesn't work. What i would like to do it's get data from a SQL server table , fill a dataset , modifiy and update the SQL table with a dataadapter. Maybe the error can be in the Update command statement... Can anyone give me a suggest ? Thank in advance George Here is the code i used: string strConn; strConn = "data source=MyDataSource;initial catalog=PTI;persist security info=False;user id=sa;workstation id=MyWksId;packet size=4096"; SqlConnection SqlConn = new SqlConnection(strConn); SqlConn.Open(); string strQry = "select * from mySQLtable"; SqlCommand cmd = new SqlCommand(strQry,SqlConn); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand=cmd; DataSet ds = new DataSet(); da.Fill(ds,"mySQLtable"); strQry = "Update mySQLtable set flag = 2"; cmd.CommandText = strQry; da.UpdateCommand=cmd; da.Update(ds,"mySQLtable"); SqlConn.Close();

Answers (2)