I would like to ask your help about parameterizing a like statement.I need to get the rows which starts with the variable code. I have a problem with my sql statement in c#.whenever i try to use this:
SqlCommand sql2= sql.SelectCommand = new SqlCommand(@"Select *
from book
where Date like @date+'%'
order by Category,Paticulars,Description,Amount",
this.connection);
sql.SelectCommand.Parameters.AddWithValue("@date", code);
SqlDataReader reader=sql2.ExecuteReader();
it does not return anything.but if i tried to add a '%' before the date it works properly.
Aucun commentaire:
Enregistrer un commentaire