VB .net text box to display count based on text in column SQ

October 9, 2014 at 03:10:03
Specs: Windows 7
VB .net text box to display count based on text in column SQL

eg. i have a sql database called users and a column called IsIn with text Yes (some will be blank) i want the textbox to display the count of all "Yes"


at a later date i would like this count to also be filtered by todays date if possible?
Thankyou!

message edited by school_techie


See More: VB .net text box to display count based on text in column SQ

Report •


#1
October 25, 2014 at 23:41:56
define a global variable counter as integer

create a FOREACH loop for each row in the database

in the loop you'll check to see if the specific cell in that specific row has the data "Yes" in it. if so, counter++ (or maybe counter += 1) else do nothing

as soon as the loop is finished you'll output your counter variable wherever you need it; lblCount.text = counter.tostring()

alternatively some people don't like global variables (they're evil!) You could do the same thing but instead of incrementing the counter variable (as you're not using one) during each loop iteration you would do something similar to:

lblCount.text = (lblCount.text.toInt + 1).tostring()

I dont know for sure if that exact syntax will work in vb.net as I typically use C# that's the idea.


Report •
Related Solutions


Ask Question