24/10/2006 | jiangws2002 1 public static DataTable ConvertDataReaderToDataTable(IDataReader reader) 2 { 3 DataTable objDataTable = new DataTable(); 4 int intFieldCount = reader.FieldCount; 5 for (int intCounter = 0; intCounter < intFieldCount; ++intCounter) 6 { 7 objDataTable.Columns.Add(reader.GetName(intCounter), reader.GetFieldType(intCounter)); 8 } 9 10 objDataTable.BeginLoadData(); 11 12 object[] objValues = new object[intFieldCount]; 13 while (reader.Read()) 14 { 15 reader.GetValues(objValues); 16 objDataTable.LoadDataRow(objValues, true); 17 } 18 reader.Close(); 19 objDataTable.EndLoadData() ; 20 21 return objDataTable; 22 } From:http://didasoft.cnblogs.com/archive/2006/01/04/310846.html