public virtual int Update(DataSet ds,DbTransaction tran)
{
int RowAffected=0;
this.Adapter.SelectCommand = this.CommandforCommandBuilder;
this.Adapter.SelectCommand.Transaction = mytran;
this.Adapter.UpdateCommand = CommandBuilder.GetUpdateCommand();
this.Adapter.InsertCommand = CommandBuilder.GetInsertCommand();
this.Adapter.DeleteCommand = CommandBuilder.GetDeleteCommand();
this.Adapter.UpdateCommand.Transaction = tran;
this.Adapter.InsertCommand.Transaction = tran;
this.Adapter.DeleteCommand.Transaction = tran;
RowAffected = this.Adapter.Update(ds, this.TableName);
return RowAffected;
}
调用以上方法保存速度超出1分钟。
问题原因:
1.有2张表,主表,子表
2.加载一张旧数据
3.更改主表数据,删除子表数据,再增加其它数据到子表
4.保存到子表需要等待1分钟左右
请问有什么办法解决?
------解决思路----------------------
代码没什么问题。你是不是数据量很大?
跟踪一下sql语句试试,几种方式:优化sql语句,或者优化数据库配置,或者使用别的更好的批量处理的办法