Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何在C中使用多个mysql查询_C#_Mysql - Fatal编程技术网

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

C# 如何在C中使用多个mysql查询,c#,mysql,C#,Mysql,如何使用类似于此的代码执行多个mysql查询?您可能会对SELECT COUNT*感兴趣,这将容易受到sql注入攻击。这简直是乞求被黑客攻击。不仅如此,它还以明文形式存储密码。这是两个最大的安全隐患。您想执行多个独立查询或包含多个查询的查询?多个独立查询好的,那么到底是什么阻止您使用多个查询?而且,如果您学会了正确地进行参数化查询,那么以后就不必忘记坏习惯。 try { string strConnection = "host=bla; database=twhalen_storage;

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

您可能会对SELECT COUNT*感兴趣,这将容易受到sql注入攻击。这简直是乞求被黑客攻击。不仅如此,它还以明文形式存储密码。这是两个最大的安全隐患。您想执行多个独立查询或包含多个查询的查询?多个独立查询好的,那么到底是什么阻止您使用多个查询?而且,如果您学会了正确地进行参数化查询,那么以后就不必忘记坏习惯。
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);
}