Like request in C # adapter

I have a data adapter that was created from my data set. I want to make this request:

Select Body WHERE Body Like '%@INPUTTEXT%'.

How can i do this? I want "@INPUTTEXT" to be a parameter, but due to "" it is plain text ...

+3
source share
3 answers

WHERE BODY Like '%' + @inputtext + '%'

+3
source

I have done this before to do what you ask for:

string cmdText = "select * from table where column like @INPUTTEXT";
SqlConnection conn = new SqlConnection(connString);
SqlCommand cmd = new SqlCommand(cmdText,conn);
cmd.Parameters.Add(new SqlParameter("@INPUTTEXT", string.Format("%{0}%",INPUTTEXT)));
+6
source

or in linq

dc.Body.where(a+> a.body.contains("InputText")).Select(a=>a.body).ToList();
0
source

Source: https://habr.com/ru/post/1788996/


All Articles