你会如何在C#中使用多个mysql查询?

时间:2013-12-10 23:11:11

标签: c# mysql

try
{
    string strConnection = "host=bla; database=twhalen_storage; username=twhalen_software; password=bla!;";
    MySqlConnection conSQL = new MySqlConnection(strConnection);
    MySqlCommand mycommand = new MySqlCommand("SELECT * FROM twhalen_storage.users WHERE username= '" + this.username_txt.Text + "'AND password= '" + this.password_txt.Text + "';", conSQL);
    MySqlDataReader myReader;
    conSQL.Open();
    myReader = mycommand.ExecuteReader();
    int count = 0;
    while (myReader.Read())
    {
        count = count + 1;
    }
    if (count == 1)
    {
        this.Hide();
        Form2 f2 = new Form2();
        f2.ShowDialog();
    }
    else
        MessageBox.Show("go away");
    conSQL.Close();
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
}

如何使用与此类似的代码执行多个mysql查询?

0 个答案:

没有答案