Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

looping through database

Status
Not open for further replies.

rahulpatel

Programmer
Jan 20, 2007
33
AU
I need to pick out all the records from my database where the customer has their checkbox state as checked. I have this so far...

Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click

        Dim Counter As Integer = 0
        Dim Number As Integer


        While CheckBox1.CheckState = CheckState.Checked
            If Number < 0 Then Exit While
            Number = Number - 1
            Counter = Counter + 1
        End While
        MsgBox("The loop ran " & Counter & " times.")

    End Sub

This code is for me to find out how many records it returns to make sure it's picking up the correct amount. I'll add more detailed code once I get it to work.

At the moment this only returns the current record. What can I add to make it loop through all the records?
 
maybe you can use a sql statement:

select count(*) as cnt from your_table
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top