我正在尝试创建一个登录页面,其中我从Server数据库获取密码和电子邮件。我想比较一下密码和电子邮件。
private void buttoninloggen_Click(object sender, EventArgs e)
{
using (SqlConnection connection = new SqlConnection(connectionstring))
{
connection.Open();
string emailinlog = textBoxEmailLogin.Text;
string passwordinlog = textBoxPasswordLogin.Text;
string vergelijken = "select * from Account where Email = @email and Password = @password";
SqlDataAdapter adapter = new SqlDataAdapter(vergelijken, connection);
MessageBox.Show("tot hier is t goed");
using (SqlCommand ophalen = new SqlCommand(vergelijken, connection))
{
ophalen.Parameters.AddWithValue("@email", emailinlog);
ophalen.Parameters.AddWithValue("@password", passwordinlog);
DataTable tafel = new DataTable();
adapter.Fill(tafel);
if (tafel.Rows.Count > 0)
{
MessageBox.Show("ingelogd");
}
}
}
}我收到以下错误消息:
System.Data.SqlClient.SqlException:‘必须声明标量变量“@email”。
我做错了什么?
发布于 2017-12-07 14:10:38
考虑将语法更改为我的程序中的工作代码:
ophalen.Parameters.Add(new SqlParameter("@email", emailinlog));https://stackoverflow.com/questions/47696841
复制相似问题