【求助】麻烦大家解释一下这段代码
//作者说这可以根据指定的sql语句来完成 添加,删除,修改等操作,但是我没看懂
public virtual int AutoUpdate(
string sql,
System.Collections.ArrayList inParam,
DataTable dataTable,
bool setCase
)
{
if (null == this.connection)
{
throw new ObjectDisposedException(this.GetType().FullName);
}
SqlCommand command = new SqlCommand(sql, this.connection);
command.CommandTimeout = this._timeout;
SetParamData(inParam, command);
if (null != this.transaction)
{
command.Transaction = this.transaction;
}
SqlDataAdapter dataAdapter = new SqlDataAdapter(command);
SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);//这个有什么用呀?
dataTable.CaseSensitive = setCase;
return dataAdapter.Update(dataTable);
}
------解决方案--------------------SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);//这个有什么用呀?
可以帮助你产生Insert、Update、Delete语句
------解决方案--------------------是的阿;传递相应的 insert delete update sql 语句去执行阿
------解决方案--------------------望文生义就知道了,有什么看不懂的?
------解决方案--------------------SqlCommandBuilder commandBuilder = new SqlCommandBuilder(dataAdapter);//
就是在你DATAGRID修改数据的时候,可以马上提交到数据库里..同步..
------解决方案--------------------