當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。