Not sure if this would be the right area...But I am wondering if it would be more efficient to use SQL instead of the ADO I am using below.

Every ADO search I do requires a for loop, and this seems to slow everything down (duh). I am under the impression if I use SQL I won't need one?

Here is my code..the bolded is the basics of the loop

VB Code:
  1. Public Sub Supports(Hours As Integer, Payband As String, Account As String)
  2. [b]RsPayband.Open "SupportPayband", cn, adOpenKeyset, adLockPessimistic, adCmdTable
  3.     RsPayband.MoveFirst
  4.     Do While RsPayband.EOF = False[/b]
  5.        'checks to see if Payband matches value in table
  6.        
  7.         If AnniversaryHappened Then
  8.             If (Payband + 1) > MaxPayband Then
  9.                 newpayband = Payband
  10.             Else
  11.                 newpayband = Payband + 1
  12.             End If
  13.            [b] If RsPayband.Fields("payband") = newpayband Then
  14.                 If strLevel <> "0" Then
  15.                     newSupportDailyTotal = ((RsPayband.Fields(strLevel) * (Hours / 5)))
  16.                 End If
  17.             End If[/b]
  18.         End If
  19.             [b]If RsPayband.Fields("Payband") = Val(Payband) Then
  20.                 If strLevel <> "0" Then
  21.                     SupportDailyTotal = ((RsPayband.Fields(strLevel) * (Hours / 5)))
  22.                 End If
  23.             End If
  24.         RsPayband.MoveNext
  25.     Loop
  26.     RsPayband.Close[/b]
  27. End Sub


I am not sure what the SQL would look like, but I am guessing something like this

VB Code:
  1. RsPayband.Open "Select * from SupportPayband", cn, adOpenKeyset, adLockPessimistic
  2.  
  3. SupportDailyTotal = "Select " + txtlevel.text + " from SupportPayband where Payband = " + txtPayband.text

Or something along those lines (I've never used SQL )

Anyways, any tips would be appreciated