我有以下代码来检查用户:
private void button1_Click(object sender, EventArgs e)
{
string ss = "SElECT * FROM 123 WHERE u=@USERNAME";
using (SqlCeConnection cn = new SqlCeConnection(@"Data Source=|DataDirectory|\123.sdf"))
{
try
{
SqlCeCommand selectCommand = new SqlCeCommand(ss, cn);
cn.Open();
selectCommand.Parameters.AddWithValue("@USERNAME", textBox1.Text);
int result = (int) selectCommand.ExecuteScalar();
if (result > 0)
MessageBox.Show("logged in");
else
MessageBox.Show("user not found");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
finally
{
cn.Close();
}
}
}
运行时出现此错误:
为什么我会收到此错误?