sql - Using wildcards with Parameters in vb.net ADO -
i have following code works fine part of program:
.commandtext = .commandtext & " , [name] = ?"
i add parameter using:
.parameters.append(searchcom.createparameter("@name", adodb.datatypeenum.adchar, adodb.parameterdirectionenum.adparaminput, 100, name.text))
this works perfectly, want search containing value in name.text. searched dozens of articles can following, returns 0 results though there definilty data matches:
.commandtext = .commandtext & " , [name] '%' + ? + '%'" .parameters.append(searchcom.createparameter("@name", adodb.datatypeenum.adchar, adodb.parameterdirectionenum.adparaminput, 100, name.text))
i have tried suggestion below, still recordset returns 0 results:
.commandtext = .commandtext & " , [name] ?" .parameters.append(searchcom.createparameter("@name", adodb.datatypeenum.adchar, adodb.parameterdirectionenum.adparaminput, 100, "%" + name.text + "%"))
i using microsoft visual studio 2015, writing in vb.net using adodb connect sql server 2014 instance.
a sql trace of codinggorilla's suggestion reveals following sql runs @ runtime. not know enough understand why not working!
exec sp_executesql n'select * qformsandname [formtype] ''r1%'' , [name] @p1 order [currentstatus], [datereceived];',n'@p1 char(100)','%jones%
please can help?
i try slight variation on that:
.commandtext = .commandtext & " , [name] ?" .parameters.append(searchcom.createparameter("@name", adodb.datatypeenum.adchar, adodb.parameterdirectionenum.adparaminput, 100, "%" + name.text + "%"))
this should work, although it's not direct answer why version of code not work.
Comments
Post a Comment