private DataTable GetDataTableFromIDataReader (IDataReader reader)
{
DataTable dt = new DataTable();
bool init = false;
dt.BeginLoadData();
object[] vals = new object[0];
while (reader.Read())
{
if (!init)
{
init = true;
int fieldCount = reader.FieldCount;
for (int i=0; i<fieldCount; i++)
{
dt.Columns.Add (reader.GetName(i), reader.GetFieldType (i));
}
vals = new object[fieldCount];
}
reader.GetValues (vals);
dt.LoadDataRow (vals, true);
}
reader.Close();
dt.EndLoadData();
return dt;
}