本文整理汇总了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;
}
}
示例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;
}
}
}