I'm trying to parameterize my SQL Statements but I'm having some trouble with the LIKE statement. I tried different solutions but nothing works. My code:
sqlCmd = new SqlCommand("SELECT " + form1.cusId.Text + "," + form1.cusName.Text" FROM " + form1.getTable() + " WHERE " + form1.getCusId() + " LIKE @filterCustomers", connection);
sqlCmd.Parameters.AddWithValue("@filterCustomers", form1.filterCus().Trim() + "%");
I'm getting
"Must declare the scalar variable @filterCustomers".
Why ist that happening? Since this is th common solution...