根据查询条件批量修改表数据
程序员文章站
2023-08-29 17:35:13
--表:table --字段:columsA、columsB、columsC、columsD void Main(){ string sql="select columsA from table"; DataTable dt=SqlHelper.executeQuery(sql); dt.rows[ ......
--表:table
--字段:columsa、columsb、columsc、columsd
void main(){
string sql="select columsa from table";
datatable dt=sqlhelper.executequery(sql);
dt.rows[0]["columsa"]="111";
sdaupdate(sql,dt)
}
public void sdaupdate(string selectsql,datatable dt)
{
try
{
sqlcommand sqlcommand = getsqlconn().createcommand();
sqlcommand.commandtext = selectsql;
sqldataadapter sdaadapter = new sqldataadapter(sqlcommand);
sqlcommandbuilder scbbuilder = new sqlcommandbuilder(sdaadapter);
sdaadapter.update(dt);
}
catch (exception ex)
{
}
}
下一篇: 嵌入式c语言编程之递归函数