|
The button calls the following method: no error is reported, but the data does not change when re-retrieving
public static void UpdateDataset(DataSet dataSet, string tableName,string connstr)
{
SqlConnection conn = new SqlConnection(connstr);
conn.Open();
string ls_sql = "select top 0 * from "+ tableName;
SqlDataAdapter da = new SqlDataAdapter(ls_sql,conn);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
ds.Clear();
da.Fill(ds,tableName);
ds = dataSet.Copy();
try
{
da.Update(ds,tableName);
}
catch(System.Data.SqlClient.SqlException e)
{
throw new Exception(e.Message);
}
finally
{
conn.Close();
da.Dispose();
cb.Dispose();
ds.Dispose();
dataSet.AcceptChanges();
}
} |
|