private object FillSchemaInternal(DataSet dataset, DataTable datatable, SchemaType schemaType, IDbCommand command, string srcTable, CommandBehavior behavior)
{
object dataTables = null;
bool restoreNullConnection = (null == command.Connection);
try
{
IDbConnection activeConnection = DbDataAdapter.GetConnection3(this, command, ADP.FillSchema);
ConnectionState originalState = ConnectionState.Open;
try
{
QuietOpen(activeConnection, out originalState);
using (IDataReader dataReader = command.ExecuteReader(behavior | CommandBehavior.SchemaOnly | CommandBehavior.KeyInfo))
{
if (null != datatable)
{ // delegate to next set of protected FillSchema methods
dataTables = FillSchema(datatable, schemaType, dataReader);
}
else
{
dataTables = FillSchema(dataset, schemaType, srcTable, dataReader);
}
}
}
finally
{
QuietClose(activeConnection, originalState);
}
}
finally
{
if (restoreNullConnection)
{
command.Transaction = null;
command.Connection = null;
}
}
return dataTables;
}