本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.GetValue方法的具体用法?C# MySqlDataReader.GetValue怎么用?C# MySqlDataReader.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlDataReader
的用法示例。
在下文中一共展示了MySqlDataReader.GetValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PopulateListView
public static void PopulateListView(ListView lst, String strQuery)
{
ListViewItem lstItem = null;
int x;
lst.Items.Clear();
conn.Open();
comm.Connection = conn;
comm.CommandText = strQuery;
reader = comm.ExecuteReader();
if (reader.HasRows)
{
while (reader.Read())
{
lstItem = lst.Items.Add(reader.GetValue(0).ToString());
for (x = 1; x < reader.FieldCount; x++)
{
lstItem.SubItems.Add(reader.GetValue(x).ToString());
}
}
}
conn.Close();
}
示例2: Course
public Course(MySqlDataReader dReader)
{
lectures = new List<Section>();
labs = new List<Section>();
iterations = new List<List<Section>>();
dReader.Read();
dept = dReader.GetValue(0).ToString();
number = (int)dReader.GetValue(1);
creditHours = (int)dReader.GetValue(4);
do
{
if (dReader[6].ToString() == "LEC")
{
if (!CheckSections(lectures, dReader))
{
lectures.Add(new Section(dReader));
}
}
else if (dReader[6].ToString() != "DSO")
{
if (!CheckSections(labs, dReader))
{
labs.Add(new Section(dReader));
}
}
} while (dReader.Read());
}
示例3: MapToEntity
/// <summary>
/// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Arbeitsspeicher'
/// </summary>
/// <param name="reader">Der Datensatz, welcher gemappt wird</param>
/// <returns>RandomAccessMemory</returns>
protected override object MapToEntity(MySqlDataReader reader)
{
RandomAccessMemory ram = new RandomAccessMemory();
ProducerDataAccess producerDataAccess = new ProducerDataAccess();
ram.Id = Int32.Parse(reader.GetValue(0).ToString());
ram.Description = reader.GetValue(1).ToString();
ram.Memory = ulong.Parse(reader.GetValue(2).ToString());
ram.ClockRate = Double.Parse(reader.GetValue(3).ToString());
ram.Producer = producerDataAccess.GetEntityById<Producer>(Int32.Parse(reader.GetValue(4).ToString()));
return ram;
}
示例4: getLine
public static string getLine(MySqlDataReader mySqlDataReader)
{
int colum = mySqlDataReader.FieldCount;
string line = "";
for(int i =0;i<colum;i++){
if(mySqlDataReader.GetValue(i) is DBNull){
line += "null"+" ";
}else{
line += mySqlDataReader.GetValue(i)+" ";
}
}
return line;
}
示例5: FinnaAkvedinOgSkilaTilBaka
//Hérna er fundinn ákveðin einstaklingur og gögning hans koma til baka
public string[] FinnaAkvedinOgSkilaTilBaka(string kennitala)
{
string[] gogn = new string[8];
if (OpenConnection() == true)
{
fyrirspurn = "SELECT id, kennitala, password, name, age, position, salary, hours FROM workers where kennitala='" + kennitala + "'"; //til að fá upplýsingarnar um starfsmanninn
nySQLskipun = new MySqlCommand(fyrirspurn, sqltenging);
sqllesari = nySQLskipun.ExecuteReader();
while (sqllesari.Read())
{
gogn[0] = sqllesari.GetValue(0).ToString(); //id-ið hans
gogn[1] = sqllesari.GetValue(1).ToString(); //kennitalan
gogn[2] = sqllesari.GetValue(2).ToString(); //lykilorðið
gogn[3] = sqllesari.GetValue(3).ToString(); //Nafnið
gogn[4] = sqllesari.GetValue(4).ToString(); //aldur
gogn[5] = sqllesari.GetValue(5).ToString(); //starfsstaða
gogn[6] = sqllesari.GetValue(6).ToString(); //laun
gogn[7] = sqllesari.GetValue(7).ToString(); //vinnutímar
}
sqllesari.Close();
CloseConnection();
return gogn;
}
return gogn;
}
示例6: DBColumnToPyObject
public static PyObject DBColumnToPyObject(int index, ref MySqlDataReader reader)
{
Type type = reader.GetFieldType(index);
switch (type.Name)
{
case "String":
return new PyString(reader.GetString(index));
case "UInt32":
case "Int32":
case "UInt16":
case "Int16":
case "SByte":
case "Byte":
return new PyInt(reader.GetInt32(index));
case "UInt64":
case "Int64":
return new PyLongLong(reader.GetInt64(index));
case "Byte[]":
return new PyBuffer((byte[])reader.GetValue(index));
case "Double":
return new PyFloat(reader.GetDouble(index));
case "Decimal":
return new PyFloat((double)reader.GetDecimal(index));
case "Boolean":
return new PyBool(reader.GetBoolean(index));
default:
Log.Error("Database", "Unhandled MySQL type " + type.Name);
break;
}
return null;
}
示例7: Logar
public bool Logar(string nickname, string senha)
{
Conexao();
bool logado = false;
string sql = "select id, nickname, senha from Usuario where nickname= @nickname ";
command = new MySqlCommand(sql, Conexao());
par = new MySqlParameter("@nickname", nickname);
par.MySqlDbType = MySqlDbType.VarChar;
command.Parameters.Add(par);
reader = command.ExecuteReader();
string senhaUsuario;
if (reader.Read())
{
senhaUsuario = reader.GetValue(reader.GetOrdinal("SENHA")).ToString();
if (senhaUsuario.Equals(senha))
{
logado = true;
}
}
FecharConexao();
return logado;
// command = new System.Data.SqlClient.SqlCommand(sql, conexão());
}
示例8: connAndRead
public void connAndRead(string sql)
{
string ans = sql;
listBox1.Items.Clear();
try
{
conn.Open();
cmd.CommandText = ans;
dr = cmd.ExecuteReader();
while (dr.Read())
{
string thisrow = "";
for (int i = 0; i < dr.FieldCount; i++)
thisrow += dr.GetValue(i).ToString() + " ";
listBox1.Items.Add(thisrow);
}
conn.Close();
}
catch (MySqlException exp)
{
conn.Close();
MessageBox.Show(exp.Message);
}
}
示例9: FinnaEinstakling
//Þessi aðferð finnu ákveðinn einstakling
public bool FinnaEinstakling(string kt)
{
string lina = null;
if (OpenConnection() == true)
{
fyrirspurn = "SELECT kennitala FROM workers where kennitala='" + kt + "'"; //Fyrispurn hvort starsfmaður er í gagnagrunninum
nySQLskipun = new MySqlCommand(fyrirspurn, sqltenging);
sqllesari = nySQLskipun.ExecuteReader();
while (sqllesari.Read())
{
for (int i = 0; i < sqllesari.FieldCount; i++)
{
lina += (sqllesari.GetValue(i).ToString());
}
}
sqltenging.Close();
if (lina != null) //ef starsfmaður fannst
{
return true;
}
else //annars er skilað false
{
return false;
}
}
else //ef tengingin mistókst er líka skilað false
{
return false;
}
}
示例10: refresh
public bool refresh()
{
listBox1.Items.Clear();
try
{
conn.Open();
cmd.CommandText = "SELECT * FROM test";
dr = cmd.ExecuteReader();
while (dr.Read())
{
string thisrow = "";
for (int i = 0; i < dr.FieldCount; i++)
{
thisrow += dr.GetValue(i).ToString() + " ";
}
listBox1.Items.Add(thisrow);
}
conn.Close();
return true;
}
catch (MySqlException expsql2)
{
MessageBox.Show(String.Format("nie udalo sie pobrac danych, blad{0}", expsql2), "Pobieranie danych", MessageBoxButtons.OK);
return false;
}
}
示例11: checkNull
public String checkNull(MySqlDataReader reader, Int16 index)
{
if (reader.IsDBNull(index))
{
return null;
}
return reader.GetValue(index).ToString();
}
示例12: MapToEntity
/// <summary>
/// Mappt einen Datensatz aus der Datenbank auf ein Objekt vom Typ 'Hersteller'
/// </summary>
/// <param name="reader">Der Datensatz, welcher gemappt wird</param>
/// <returns>Producer</returns>
protected override object MapToEntity(MySqlDataReader reader)
{
Producer producer = new Producer();
producer.Id = Int32.Parse(reader.GetValue(0).ToString());
producer.CompanyName = reader.GetValue(1).ToString();
producer.PhoneNumber = reader.GetValue(2).ToString();
producer.Email = reader.GetValue(3).ToString();
producer.Website = reader.GetValue(4).ToString();
producer.PostalCode = uint.Parse(reader.GetValue(5).ToString());
producer.Place = reader.GetValue(6).ToString();
producer.Street = reader.GetValue(7).ToString();
producer.HouseNumber = uint.Parse(reader.GetValue(8).ToString());
return producer;
}
示例13: getLine
private static string getLine(MySqlDataReader mySqlDataReader)
{
string line = "";
for (int index = 0; index < mySqlDataReader.FieldCount; index++) {
object value = mySqlDataReader.GetValue (index);
if (value is DBNull)
value = "null";
line = line + value + " ";
}
return line;
}
示例14: getline
private static string getline(MySqlDataReader mysqlDataReader)
{
int col=mysqlDataReader.FieldCount;
string linea=" ";
for(int i=0;i<col;i++){
if (mysqlDataReader.GetValue(i) is DBNull)
linea+="null ";
else
linea+=mysqlDataReader.GetValue(i)+" ";
}
return linea;
}
示例15: FinnaAkvedinOgSkila
public string[] FinnaAkvedinOgSkila(string user_id)
{
string[] gogn = new string[5];
if (OpenConnection() == true)
{
fyrirspurn = "SELECT user_id,nafn,Simi,Lykilord,Netfang FROM user WHERE user_id='" + user_id + "'";
nySQLskipun = new MySqlCommand(fyrirspurn, sqltenging);
sqllesari = nySQLskipun.ExecuteReader();
while (sqllesari.Read())
{
gogn[0] = sqllesari.GetValue(0).ToString();
gogn[1] = sqllesari.GetValue(1).ToString();
gogn[2] = sqllesari.GetValue(2).ToString();
gogn[3] = sqllesari.GetValue(3).ToString();
gogn[3] = sqllesari.GetValue(4).ToString();
}
sqllesari.Close();
CloseConnection();
return gogn;
}
return gogn;
}