if (dataReader.HasRows)
{
dtReturn = CreateTableBySchemaTable(dataReader.GetSchemaTable());
value = new object[dataReader.FieldCount];
while (dataReader.Read())
{
dataReader.GetValues(value);
dtReturn.LoadDataRow(value, true);
}
value = null;
}
}
catch (Exception err)
{}
finally
{
dataReader.Close();
sqlComm.Connection.Close();
sqlComm.Dispose();
}
return dtReturn;
}
protected DataTable CreateTableBySchemaTable(DataTable pSchemaTable)
{
DataTable dtReturn = new DataTable();
DataColumn dc = null;
DataRow dr = null;
for (int i = 0; i < pSchemaTable.Rows.Count; i++)
{
dr = pSchemaTable.Rows[i];
dc = new DataColumn(dr["ColumnName"].ToString(), dr["DataType"] as Type);
dtReturn.Columns.Add(dc);
}
dr = null;
dc = null;
return dtReturn;
}