本文整理汇总了C#中System.Data.OleDb.OleDbDataReader.GetSchemaTable方法的典型用法代码示例。如果您正苦于以下问题:C# OleDbDataReader.GetSchemaTable方法的具体用法?C# OleDbDataReader.GetSchemaTable怎么用?C# OleDbDataReader.GetSchemaTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Data.OleDb.OleDbDataReader
的用法示例。
在下文中一共展示了OleDbDataReader.GetSchemaTable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadRow
public void LoadRow(OleDbDataReader reader)
{
var schema = reader.GetSchemaTable();
foreach (var pi in this.GetType().GetProperties())
{
if (schema.Select("ColumnName='" + pi.Name + "'").Length > 0)
{
var value = reader.GetValue(reader.GetOrdinal(pi.Name));
if (value != null)
pi.SetValue(this, value, null);
}
}
}
示例2: ConvertDataReaderToDataSet
private DataSet ConvertDataReaderToDataSet(OleDbDataReader reader)
{
DataSet dataSet = new DataSet();
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["ColumnName"].GetType());
dataTable.Columns.Add(column);
}
while (reader.Read())
{
DataRow dataRow = dataTable.NewRow();
for (int cntr = 0; cntr < reader.FieldCount; ++cntr)
{
dataRow[cntr] = reader.GetValue(cntr);
}
dataTable.Rows.Add(dataRow);
}
dataSet.Tables.Add(dataTable);
return dataSet;
}
示例3: DataReader2DataSet
public DataSet DataReader2DataSet ( OleDbDataReader reader )
{
DataSet dataSet = new DataSet ();
do
{
// Create new data table
DataTable schemaTable = reader.GetSchemaTable ();
DataTable dataTable = new DataTable ();
if ( schemaTable != null )
{
// A query returning records was executed
for ( int i = 0 ; i < schemaTable.Rows.Count ; i++ )
{
DataRow dataRow = schemaTable.Rows [ i ];
// Create a column name that is unique in the data table
string columnName = ( string ) dataRow [ "ColumnName" ];
// Add the column definition to the data table
DataColumn column = new DataColumn ( columnName , ( Type ) dataRow [ "DataType" ] );
dataTable.Columns.Add ( column );
}
dataSet.Tables.Add ( dataTable );
// Fill the data table we just created
while ( reader.Read () )
{
DataRow dataRow = dataTable.NewRow ();
for ( int i = 0 ; i < reader.FieldCount ; i++ )
dataRow [ i ] = reader.GetValue ( i );
dataTable.Rows.Add ( dataRow );
}
}
else
{
// No records were returned
DataColumn column = new DataColumn ( "RowsAffected" );
dataTable.Columns.Add ( column );
dataSet.Tables.Add ( dataTable );
DataRow dataRow = dataTable.NewRow ();
dataRow [ 0 ] = reader.RecordsAffected;
dataTable.Rows.Add ( dataRow );
}
}
while ( reader.NextResult () );
return dataSet;
}
示例4: CollectResultsInList
// Methods
protected bool CollectResultsInList(ArrayList results, OleDbDataReader resultSet)
{
int count = results.Count;
try
{
Hashtable hashtable = new Hashtable();
foreach (DataRow row in resultSet.GetSchemaTable().Rows)
{
hashtable.Add(row["ColumnName"].ToString(), null);
}
Hashtable hashtable2 = null;
while (resultSet.Read())
{
hashtable2 = (Hashtable)hashtable.Clone();
foreach (string str in hashtable.Keys)
{
hashtable2[str] = resultSet[str];
if (hashtable2[str] == null)
{
hashtable2[str] = "";
}
}
results.Add(hashtable2);
}
}
catch (Exception exception)
{
this.error.message = "An error occurred while collecting the results of your query.";
this.error.info = exception.ToString();
}
return (results.Count > count);
}