I have the following code to check a user:
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();
}
}
}
I get this error when I run it:
Why am I getting this error?