如何防止这些代码被 SQL 注入?这是我正在学习的登录系统。这是代码!
\n if (!(string.IsNullOrWhiteSpace(textBox1.Text)) && !(string.IsNullOrWhiteSpace(textBox2.Text)))\n {\n\n MySqlConnection mcon = new MySqlConnection("datasource = 127.0.0.1; port = 3306; username = root; password = ; database = rpgmaster;");\n\n mcon.Open();\n\n DataTable table = new DataTable();\n\n MySqlDataAdapter adapter = new MySqlDataAdapter("Select * From users where Username = '" + textBox2.Text + "' and password = '" + textBox1.Text + "'", mcon);\n \n adapter.Fill(table);\n\n if (table.Rows.Count <= 0)\n {\n MessageBox.Show("Voc\xc3\xaa n\xc3\xa3o est\xc3\xa1 registrado!");\n }\n else\n {\n MessageBox.Show("Logado com sucesso! ");\n }\n\n mcon.Close();\n }\n …Run Code Online (Sandbox Code Playgroud)