sql server - Stored Procedure Where Parameter SqlDbType -
i have combobox , textbox. use combobox value @criteria , texbox value @value when execute there no data showed up. analyzing problem within :
select * table @criteria '%'+@value+'%'
from tested, data showed if value part of @criteria string. if @criteria 'name' data showed if @value 'n' or 'a' or 'm' or 'e'
how can make works?
openconn() cmd.commandtype = commandtype.storedprocedure cmd.commandtext = "find" cmd.parameters.clear() cmd.parameters.add("@criteria", sqldbtype.varchar).value = cmbcriteria.text cmd.parameters.add("@value", sqldbtype.varchar).value = txtvalue.text dr = cmd.executereader listview1.items.clear() while dr.read dim lv listviewitem lv = listview1.items.add(dr("no")) lv.subitems.add(dr("name")) lv.subitems.add(dr("address")) loop closeconn()
i think maybe expecting "@criteria" database field name. parameters in ado.net (and in modern methods of database access) refer data values , can never used database field names.
Comments
Post a Comment