当前位置: 首页>>代码示例>>C#>>正文


C# OleDbDataReader.GetSchemaTable方法代码示例

本文整理汇总了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);
         }
     }
 }
开发者ID:jb3622,项目名称:Jalapeno,代码行数:13,代码来源:ItemBase.cs

示例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;
        }
开发者ID:CamilleValley,项目名称:SnipeAgent,代码行数:29,代码来源:DataBaseAdaptor.cs

示例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;
        }
开发者ID:cheng521yun,项目名称:https---github.com-frontflag-FTMZ_CY,代码行数:53,代码来源:OleDb.cs

示例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);
 }
开发者ID:built,项目名称:BoxBoy,代码行数:33,代码来源:SqlBoxDatabase.cs


注:本文中的System.Data.OleDb.OleDbDataReader.GetSchemaTable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。