本文整理汇总了C#中MySql.Data.MySqlClient.MySqlDataReader.Read方法的典型用法代码示例。如果您正苦于以下问题:C# MySqlDataReader.Read方法的具体用法?C# MySqlDataReader.Read怎么用?C# MySqlDataReader.Read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySql.Data.MySqlClient.MySqlDataReader
的用法示例。
在下文中一共展示了MySqlDataReader.Read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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());
}
示例2: napuni
public void napuni()
{
Baza baza = new Baza();
string kabinet, mejl, konsultacije = "";
string biografija = "Нема описа.";
string aktivnost = "Нема описа.";
upit = "SELECT * FROM profesori WHERE idprofesor = " + id;
using (reader = baza.izvrsiUpit(upit))
{
while (reader.Read())
{
if (reader.GetString("biografija") != "") biografija = reader.GetString("biografija");
if (reader.GetString("aktivnost") != "") aktivnost = reader.GetString("aktivnost");
profesor = new ProfesorC(reader.GetString("idProfesor"), reader.GetString("imePrezime"), reader.GetString("titula"), reader.GetString("zvanje"), reader.GetString("slika"), reader.GetString("konsultacije"), reader.GetString("kabinet"), reader.GetString("mail"), biografija, aktivnost);
gridProfesor.DataContext = profesor;
}
}
upit1 = "SELECT * FROM predmeti WHERE id_predm IN (SELECT id_predm FROM pplink WHERE id_prof = " + id + ")";
using (reader = baza.izvrsiUpit(upit1))
{
while (reader.Read())
{
Predmet p = new Predmet(reader.GetString("id_predm"), reader.GetString("naziv"));
lvPredmeti.Items.Add(p);
}
}
}
示例3: Login
public static void Login(string username, string passhash)
{
if (Validate(username, passhash))
{
time = string.Format("{0:yyyy.MM.dd 0:HH:mm:ss tt}", DateTime.Now);
rdr = new MySqlCommand("SELECT lastin FROM login WHERE username='" + username + "';", conn).ExecuteReader();
while (rdr.Read()) {
Console.WriteLine("User's last sign in was: " + rdr["lastin"]);
}
rdr.Close();
new MySqlCommand("UPDATE login SET lastin='" + time + "' WHERE username='" + username + "';", conn).ExecuteNonQuery();
}
Console.WriteLine("HHHHhhhh");
//TODO:
//
//If the username exists, check that the password hash matches.
//
//If the username does not exist, be like "No user found".
//
//Else, If the password hash matches, Sign in.
//Set the current player to active
//forward/bind socket to control an Object?
//Note the timestamp and IP of the login in the database
//Send all of the necessary information back to the client:
}
示例4: findAll
public void findAll()
{
db = new Database();
brands.Clear();
brandQuery = new MySqlCommand();
brandQuery.Connection = db.Connection();
brandQuery.CommandText = "SELECT * FROM brand ORDER BY brandname ASC";
this.brandResult = brandQuery.ExecuteReader();
while (brandResult.Read())
{
if (!brandResult.IsDBNull(0))
{
idbrand = brandResult.GetInt32(0);
}
if (!brandResult.IsDBNull(1))
{
brandname = brandResult.GetString(1);
}
brands.Add(new Brand { idbrand = this.idbrand, brandname = this.brandname});
}
db.Close();
}
示例5: Login
public int Login(TextBox utilizador, TextBox password)
{
Conetar();
int valor = 0;
string query = "SELECT * FROM conta WHERE utilizador='" + utilizador.Text + "' AND password='" + password.Text + "';";
_cmdDataBase = new MySqlCommand(query, _conDataBase);
try
{
_conDataBase.Open();
_myReader = _cmdDataBase.ExecuteReader();
while (_myReader.Read())
{
}
if (_myReader.HasRows)
{
MessageBox.Show("Login Correto");
valor = 1;
}
else
{
MessageBox.Show("Login Incorreto! Volte a Introduzir as suas Credenciais");
valor = 0;
}
_myReader.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
return valor;
}
示例6: show
public static void show(MySqlDataReader mySqlDataReader)
{
// METODO QUE MUESTRA TODO EL CONETNIDO DE LA TABLA
Console.WriteLine ("FILAS : "); // EL SHOW MUESTRA EL SHOWROW (FILA). EL SHOWROW MUESTRA LA FILA
while (mySqlDataReader.Read())
showRow (mySqlDataReader);
}
示例7: 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();
}
示例8: LoadSector
public List<Sector> LoadSector()
{
try
{
using (MySqlConnection cn = new MySqlConnection((clsCon=new Connection(this.user)).Parameters()))
{
listSec = new List<Sector>();
cn.Open();
sql = "select * from asada.view_sectores";
cmd = new MySqlCommand(sql, cn);
reader = cmd.ExecuteReader();
while (reader.Read())
{
sec = new Sector();
sec.Code = reader.GetString(0);
sec.Consecutive = reader.GetInt32(1);
sec.Description = reader.GetString(2);
listSec.Add(sec);
}
reader.Close();
return listSec;
}
}
catch (Exception)
{
throw;
}
}
示例9: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
nid = Request.QueryString["news_id"];
try
{
con.Open();
cmd = new MySqlCommand("select * from news where newsid='" + nid + "'", con);
dr = cmd.ExecuteReader();
if (dr.Read())
{
article.Text = "<h1 style='font-size:25px'>" + dr.GetString("headline").Substring(0, 1).ToUpper() + dr.GetString("headline").Substring(1).ToLower() + "</h1><br/><br/><img alt='' src='../images/tag.png' /> Alumni News<br/><br/>";
article.Text += " <p style='text-align: justify;'>" + dr.GetString("story") + "</p>";
article.Text += "<p style='text-align: justify;'><a href='http://alumni.ssn.edu.in/alumni-stories.php'>http://alumni.ssn.edu.in/alumni-stories.php</a></p>";
dr.Close();
con.Close();
}
else
{
rerr.Visible = true;
}
}
catch (Exception ex)
{
CreateLogFile log = new CreateLogFile();
log.ErrorLog(Server.MapPath("../Logs/Errorlog"), "Page load method of NewsRead page for " + Session["loginname"] + ":" + ex.Message);
}
}
示例10: BuscaUsuario
public static Atributos BuscaUsuario(int BuscaUsuario)
{
try
{
Con = Conexao.GetConnection();
Conexao.AbrirConexao(Con);
Sql = "Select * From TbMorador where CodMorador = " + BuscaUsuario + "";
Cmd = new MySqlCommand(Sql, Con);
Dr = Cmd.ExecuteReader();
if (Dr.Read())
{
Morador.NomeMorador = Convert.ToString(Dr["NomeMorador"]).Trim();
Morador.Bloco = Convert.ToString(Dr["Bloco"]).Trim();
Morador.Apartamento = Convert.ToString(Dr["Apartamento"]).Trim();
Morador.Senha = Convert.ToString(Dr["Senha"]).Trim();
return Morador;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw new Exception("Erro Ao Busca Usuario :" + ex);
}
}
示例11: CheckLogin
public LoginCode CheckLogin(string username, string password)
{
string tusername = "", tpassword = "";
string sql = "SELECT * from user where user='"+username+"'";
MySqlCommand cmd = new MySqlCommand(sql, this.myCon);
myCon.Open();
myRead = cmd.ExecuteReader();
myCon.Close();
while (myRead.Read())
{
tusername = myRead.GetString("username");
tpassword = myRead.GetString("password");
}
if (tusername != null)
{
if (tpassword == password)
{
return LoginCode.LOGIN_SUCCESS;
}
}
else
{
}
return LoginCode.PASSWORD_INCORRECT;
}
示例12: CheckUserAccount
/// <summary>
/// Check if the account exist in the database.
/// </summary>
/// <param name="username"></param>
/// <param name="password"></param>
public void CheckUserAccount(string username, string password)
{
Reader.Close();
try
{
CheckUser:
{
Reader = mysql_command.ExecuteReader(); // Initalize our reader
if (!Reader.IsClosed)
{
if (Reader.Read())
{ // Reader is reading so we must close it once its finished
if (username == (EngineDatabase.DatabaseManager.Reader["user"].ToString())
&& password == (EngineDatabase.DatabaseManager.Reader["password"].ToString())) // Check the user in the database
{
id = (Int32)Reader["id"]; // Store the player's id into Int32 var
Player[id].id = (Int32)Reader["id"]; ; // Store the player's id into player struct
Player[id].isFirstLogin = (Int32)Reader["first_login"]; // Store the first_login boolean into the player struct
switch (Player[id].isFirstLogin) // Check if the player already connected before
{
case 0: // He did not connected before
InsertEntries(); // Create a new account in the database (ingame part is still in progress...)
break;
case 1: // He connected before
ReadEntries(); // Load existing account data
break;
}
}
else {
Player[id].isConnected =
false;
}
mysql_connection.Close();
}
}
}
switch(mysql_connection.State)
{
case ConnectionState.Open:
goto CheckUser; // Check user account
case ConnectionState.Closed:
if (Player[id].isConnected)
error("User already logged."); // Well its not considered as error anymore...
else {
mysql_connection.Open();
goto CheckUser; // Check user account
}
break;
case ConnectionState.Broken:
error("Connection between MySQL and StreetEngine is broken.");
break;
}
}
catch (Exception x) { error(x.ToString()); }
}
示例13: LogIn
void LogIn(NetworkMessage netMsg, InfoMessage msg)
{
bool loggedIn = false;
string query = "SELECT * FROM shogi.players WHERE players_email = \"" + msg.email + "\"";
if (con.State.ToString () != "Open")
con.Open ();
using (con) {
using (cmd = new MySqlCommand (query, con)) {
rdr = cmd.ExecuteReader();
if (rdr.HasRows) {
rdr.Read ();
if (msg.password == rdr["players_password"].ToString ()) {
incomeMessages.text += netMsg.conn.address + " logged in as " + msg.email + "\n";
loggedIn = true;
}
else
incomeMessages.text += netMsg.conn.address + " failed logging in for wrong password " + msg.password + "\n";
}
else
incomeMessages.text += netMsg.conn.address + " failed logging in for no entry " + msg.email + "\n";
rdr.Dispose ();
}
string queryIP = "UPDATE shogi.players SET players_ip = \"" + netMsg.conn.address + "\" WHERE players_email = \"" + msg.email + "\"";
if (loggedIn) {
using (cmd = new MySqlCommand (queryIP, con))
cmd.ExecuteNonQuery ();
msg.goal = "loggedin";
NetworkServer.SendToClient(netMsg.conn.connectionId, MyMsgType.Info, msg);
}
}
}
示例14: 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());
}
示例15: LoadTarifa
public List<Tarifa> LoadTarifa()
{
try
{
using (MySqlConnection cn = new MySqlConnection((clsCon = new Connection(this.user)).Parameters()))
{
lisTrf = new List<Tarifa>();
cn.Open();
sql = "select * from asada.view_tarifas";
cmd = new MySqlCommand(sql, cn);
reader = cmd.ExecuteReader();
while (reader.Read())
{
trf = new Tarifa();
trf.Code = reader.GetString(0);
trf.FixAmount = float.Parse(reader.GetString(1));
trf.MetAmount = float.Parse(reader.GetString(2));
trf.RateHidrant = float.Parse(reader.GetString(3));
trf.TypeAppString = reader.GetString(4);
lisTrf.Add(trf);
}
reader.Close();
return lisTrf;
}
}
catch (Exception)
{
throw;
}
}