public DataSet ConvertDataReaderToDataSet(OleDbDataReader reader)
{
DataSet dataSet = new DataSet();
DataTable schemaTable = new DataTable();
schemaTable = reader.GetSchemaTable();
DataTable dataTable = new DataTable();
for (int cntr = 0; cntr < schemaTable.Rows.Count; ++cntr)
{
DataRow dataRow = schemaTable.Rows[cntr];
string columnName = dataRow["ColumnName"].ToString();
DataColumn column = new DataColumn(columnName, dataRow.GetType());
dataTable.Columns.Add(column);
}
dataSet.Tables.Add(dataTable);
while (reader.Read())
{
DataRow dataRow = dataTable.NewRow();
for (int cntr = 0; cntr < reader.FieldCount; ++cntr)
{
dataRow[cntr] = reader.GetValue(cntr);
}
}
|