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


C# MySqlDataReader.GetValues方法代码示例

本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.GetValues方法的具体用法?C# MySqlDataReader.GetValues怎么用?C# MySqlDataReader.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MySql.Data.MySqlClient.MySqlDataReader的用法示例。


在下文中一共展示了MySqlDataReader.GetValues方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetConvertDataReaderToDataTable

        /// <summary> 
        /// DataReader格式转换成DataTable 
        /// </summary> 
        /// <param name="DataReader">OleDbDataReader</param> 
        private DataTable GetConvertDataReaderToDataTable(MySqlDataReader reader)
        {
            DataTable objDataTable = new DataTable("TmpDataTable");
            int intCounter;

            try
            {
                //获取当前行中的列数;
                int intFieldCount = reader.FieldCount;

                for (intCounter = 0; intCounter <= intFieldCount - 1; intCounter++)
                {
                    objDataTable.Columns.Add(reader.GetName(intCounter), reader.GetFieldType(intCounter));
                }

                //populate   datatable
                objDataTable.BeginLoadData();

                //object[]   objValues   =   new   object[intFieldCount   -1];
                object[] objValues = new object[intFieldCount];

                while (reader.Read())
                {
                    reader.GetValues(objValues);
                    objDataTable.LoadDataRow(objValues, true);
                }
                reader.Close();

                objDataTable.EndLoadData();

                return objDataTable;

            }
            catch (MySqlException ex)
            {
                throw ex;
            }
        }
开发者ID:xlgwr,项目名称:RFID,代码行数:42,代码来源:CMySQLConnect.cs

示例2: DBResults

        /// <summary>
        ///     Constructs an instance of this class.
        /// </summary>
        /// <param name="command">Command these results are for.</param>
        /// <param name="reader">Data reader to extract results with.</param>
        public DBResults(MySqlCommand command, MySqlDataReader reader)
        {
            m_rowsAffected = reader.RecordsAffected;
            m_lastInsertID = command.LastInsertedId;

            if (reader.HasRows == true)
            {
                m_rowsAffected = 0;

                // Read in each row.
                while (reader.Read())
                {
                    // Make a new row instance to hold information about this row.
                    DBRow row = new DBRow();

                    // Get all values.
                    object[] values = new object[reader.FieldCount];
                    reader.GetValues(values);

                    // Enter values into array based on column names.
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        string name = reader.GetName(i);
                        row[name] = values[i] is System.DBNull ? null : values[i];
                    }

                    // Insert into rows array.
                    if (m_rowsAffected >= m_rows.Length)
                    {
                        DBRow[] newArray = new DBRow[m_rows.Length * 2];
                        Array.Copy(m_rows, newArray, m_rows.Length);
                        m_rows = newArray;
                    }
                    m_rows[m_rowsAffected++] = row;
                }
            }
        }
开发者ID:HampsterEater,项目名称:Dynammo,代码行数:42,代码来源:DBConnection.cs


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