I am getting error "Must declare scalar variable @uname and @pw". I have tried many methods but its not working. please guide me to find the issue in my belo code.
- private void button1_Click(object sender, EventArgs e)
- {
- OleDbConnection con = new OleDbConnection(@"Provider=SQLOLEDB;Data Source=DESKTOP\SQLEXPRESS;User ID=sa; Password = pwd; Initial Catalog=database; Integrated secutity=SSPI");
- con.Open();
- OleDbCommand cmd = new OleDbCommand("select Username,password from login where Username=@uname and password=@pw", con);
- OleDbDataAdapter da = new OleDbDataAdapter(cmd);
- cmd.Parameters.Clear();
-
-
- DataTable dt = new DataTable();
- da.Fill(dt);
- if (dt.Rows.Count > 0)
- {
- MessageBox.Show("success");
- }
- else
- {
- MessageBox.Show("incorrect");
- }
- con.Close();}