62,269
社区成员
发帖
与我相关
我的任务
分享public int Fill(DataTable dataTable)
{
int num;
IntPtr ptr;
Bid.ScopeEnter(out ptr, "<comm.DbDataAdapter.Fill|API> %d#, dataTable\n", base.ObjectID);
try
{
DataTable[] dataTables = new DataTable[] { dataTable };
IDbCommand selectCommand = this._IDbDataAdapter.SelectCommand;
CommandBehavior fillCommandBehavior = this.FillCommandBehavior;
num = this.Fill(dataTables, 0, 0, selectCommand, fillCommandBehavior);
}
finally
{
Bid.ScopeLeave(ref ptr);
}
return num;
}
protected virtual int Fill(DataTable[] dataTables, int startRecord, int maxRecords, IDbCommand command, CommandBehavior behavior)
{
int num;
IntPtr ptr;
Bid.ScopeEnter(out ptr, "<comm.DbDataAdapter.Fill|API> %d#, dataTables[], startRecord, maxRecords, command, behavior=%d{ds.CommandBehavior}\n", base.ObjectID, (int) behavior);
try
{
if (((dataTables == null) || (dataTables.Length == 0)) || (dataTables[0] == null))
{
throw ADP.FillRequires("dataTable");
}
if (startRecord < 0)
{
throw ADP.InvalidStartRecord("startRecord", startRecord);
}
if (maxRecords < 0)
{
throw ADP.InvalidMaxRecords("maxRecords", maxRecords);
}
if ((1 < dataTables.Length) && ((startRecord != 0) || (maxRecords != 0)))
{
throw ADP.OnlyOneTableForStartRecordOrMaxRecords();
}
if (command == null)
{
throw ADP.MissingSelectCommand("Fill");
}
if (1 == dataTables.Length)
{
behavior |= CommandBehavior.SingleResult;
}
num = this.FillInternal(null, dataTables, startRecord, maxRecords, null, command, behavior);
}
finally
{
Bid.ScopeLeave(ref ptr);
}
return num;
}
private int FillInternal(DataSet dataset, DataTable[] datatables, int startRecord, int maxRecords, string srcTable, IDbCommand command, CommandBehavior behavior)
{
bool flag = null == command.Connection;
try
{
IDbConnection connection = GetConnection3(this, command, "Fill");
ConnectionState open = ConnectionState.Open;
if (MissingSchemaAction.AddWithKey == base.MissingSchemaAction)
{
behavior |= CommandBehavior.KeyInfo;
}
try
{
QuietOpen(connection, out open);
behavior |= CommandBehavior.SequentialAccess;
using (IDataReader reader = null)
{
reader = command.ExecuteReader(behavior);
if (datatables != null)
{
return this.Fill(datatables, reader, startRecord, maxRecords);
}
return this.Fill(dataset, srcTable, reader, startRecord, maxRecords);
}
}
finally
{
QuietClose(connection, open);
}
}
finally
{
if (flag)
{
command.Transaction = null;
command.Connection = null;
}
}
return 0;
}