public static void UpdateDataTable(string connectionString, string sql, CommandType type, DataTable table,params SqlParameter[] commandParameters)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.CommandType = type;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
foreach (SqlParameter parameter in commandParameters)
{
adapter.UpdateCommand.Parameters.Add(parameter);
}
adapter.Update(table);
}
}
这样能更新数据么?准备更新一个绑定存储过程的一个DataTable
SMILET
一只萌萌小番薯
慕盖茨4494581