Checkboxlist control help!

netuser

New member
Joined
Apr 13, 2005
Messages
1
Programming Experience
1-3
hi,
I am a new to VB.NET.Currently doing a project on it.I am using a checkboxlist control with values like 'Computer', 'Printer','Fax' etc.
When the user finishes selecting/checking the boxes, i have to put the values to the database using a SELECT statement like,
SELECT computer,Fax FROM TABLE;
I want to pass "computer,fax" as a whole string with the comma to the SELECT statement(dynamically) or if three boxes were checked then all the three values with the comma.
How can this be done?
 
VB.NET:
'assuming your table has a column computer,printer,fax..
'cn is your connection
dim cm as new sqlcommand("select * from sampletable",cn)
dim dr as sqldatareader=cm.executereader
cn.open()
dim s as string
'dr(0) is the computer
'dr(1) is the printer
'dr(2) is the fax
while dr.read
s = dr(0).tostring & ", " & dr(1).tostring & ", " & dr(2).tostring
end while
dr.close()
cn.close()
messagebox.show(s)
 
Back
Top