Click here to Skip to main content
14,983,551 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi yall. I need to fetch the ids of the items that have been checked in a checkedlistbox from the database. Please help!
dbparamcollection param =new dbparamcollection();   stringbuilder cmd =new stringbuilder(select id from table where item like @rice);    foreach(object item in checklistbox1.checkeditems)  { param.add(new dbparameter("@rice", item) );  } datatable sub=helper.executedatatable(cmd.tostring, param);
its not working any ideas. Am using dbparameter not sqlparam
Posted

1 solution

You are overriding the parameters yourself. Only the last one will be used.
Try using "select id from table where item in (@params)" and build params as list of quoted strings (" 'p1','p2'.... ")
You might be limited to the number of elements in IN clause (256 ?)
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900