0
我是使用ADO.NET建立的,我尝试使用DataSet更新表。 O客户端我有一个表的数据集。我在服务端发送这个数据集(这是ASP.NET Web服务)。 在服务端我尝试更新数据库表,但它不工作。如何使用DataSet更新数据库表
公共BOOL更新(DataSet的DS) {
SqlConnection conn = null;
SqlDataAdapter da = null;
SqlCommand cmd = null;
try
{
string sql = "UPDATE * FROM Tab1";
string connStr = WebConfigurationManager.ConnectionStrings["Employees"].ConnectionString;
conn = new SqlConnection(connStr);
conn.Open();
cmd=new SqlCommand(sql,conn);
da = new SqlDataAdapter(sql, conn);
da.UpdateCommand = cmd;
da.Update(ds.Tables[0]);
return true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (conn != null)
conn.Close();
if (da != null)
da.Dispose();
}
}
在哪里可以是问题吗?