I have the following code:
sql =
"select distinct [name] from tblCustomers left outer join tblCustomerInfo on tblCustomers.Id = tblCustomerInfo.CustomerId
where (tblCustomer.Name LIKE '%@SEARCH%' OR tblCustomerInfo.Info LIKE '%@SEARCH%');";
using (SqlCommand command = new SqlCommand(sql, Connection))
{
command.Parameters.AddWithValue("@SEARCH",searchString);
.
.
.
}
This does not work, I tried this as well:
sql =
"select distinct [name] from tblCustomers left outer join tblCustomerInfo on tblCustomers.Id = tblCustomerInfo.CustomerId
where (tblCustomer.Name LIKE @SEARCH OR tblCustomerInfo.Info LIKE @SEARCH );";
using (SqlCommand command = new SqlCommand(sql, Connection))
{
command.Parameters.AddWithValue("@SEARCH","'%"+searchString + "%'");
.
.
.
}
but this does not work as well. What is going wrong? Any suggestions?