//作者说这可以根据指定的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);
}
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);
}
就是在你DATAGRID修改数据的时候,可以马上提交到数据库里..同步..
说的很清楚~
如果不写的话会有什么影响吗?不理解。
比如说我传了一条 select 语句进去(AutoUpdate),想完成删除工作,可能吗?
要是想删除的话,我还得传delect语句进去吧。
GetDeleteCommand
GetInsertCommand
GetUpdateCommand
方法