i have an sql case statement like this
select Distinct y.SupplierID,y.Name,y.AddWho ,
"StatusDesc=CASE when y.status='N' then 'NEW' " & _
"when y.status='B' then 'BLACKLISTED'" & _
"when y.status='Q' then 'QUALIFIED'" & _
"when y.status='R' then 'REJECTED' end , " & _
"FlowStatusDesc = CASE when y.flowstatus='RC' then 'UNDER REVIEW'" & _
"when y.flowstatus='PE' then 'POTENTIAL EXCLUSIVE'" & _
"when y.flowstatus='PO' then 'POTENTIAL ORDINARY' ELSE '' end," & _
"OrderNo=case when y.status='N' and flowstatus='' then '1'" & _
"when y.status='N' and y.flowstatus<>'' then '2' " & _
"when y.status='R' and y.flowstatus='' then '3'" & _
"when y.status='R' and y.flowstatus<>'' then '4'" & _
"when y.status='Q' and y.flowstatus='' then '5'" & _
"when y.status='Q' and y.flowstatus<>'' then '6'" & _
"when y.status='B' and y.flowstatus='' then '7'" & _
"when y.status='B' and y.flowstatus<>'' then '8' else '9' end " & _
"from AP_Supplier y" & _
" left outer join SC_User u on y.addwho=u.userid " & _
"left outer join SC_Company co on co.companycode=u.companycode " & _
"where flowstatus is not null " & _
"group by y.SupplierID,y.name,y.status,y.flowstatus,y.addwho " & _
"order by orderno"
how if can i load all the case statements condition like “new”, “qualified’, “registered” and the flowstatuses into a combobox on vb.net? can you give me an example? i’ve tried doing this for quite some time.thanks.
There are a lot of ways to do so, the first one is to populate the combobox from a list. In this case you should have a class, something like:
then a list of the statuses you have:
Then you can easily populate the combox from this list using the two properties:
ValueMember.DisplayMember.like so:
The second way to do so, is to have a table or a temp table, contains these list of values like so:
Then you can use it the same way before using a data source that reads from this table and populate it. But this solution will make your query easier. You can
JOINwith this table like so:Note that: Your table this way, needs to be refactored if possible, it would be better to get rid of these statuses names and have a new table
Statuseswith the id as a foreign key in the second table.