根據查詢條件批量修改表數據

--表:table sql

--字段:columsA、columsB、columsC、columsDui

void Main(){spa

string sql="select columsA from table";string

DataTable dt=SqlHelper.executeQuery(sql);io

dt.rows[0]["columsA"]="111";table

sdaUpdate(sql,dt)date

}select

 

public void sdaUpdate(string selectSql,DataTable dt)
{
  try
  {
    SqlCommand sqlCommand = GetSqlConn().CreateCommand();
    sqlCommand.CommandText = selectSql;tab

    SqlDataAdapter sdaAdapter = new SqlDataAdapter(sqlCommand);co

    SqlCommandBuilder scbBuilder = new SqlCommandBuilder(sdaAdapter);

    sdaAdapter.Update(dt);
}
catch (Exception ex)
{

} }

相關文章
相關標籤/搜索