Thursday, March 31, 2011

Function to find row count from database in vbscript

Function rowCount()
   
    Dim cnt As Integer
   
    cnt = 0
   
    sqlquery = "enter here Select query"
    Set rs = CreateObject("adodb.recordset")
    rs.Open sqlquery, con
    If rs.BOF = False And rs.EOF = False Then
   
        rs.movefirst
   
        While Not rs.EOF
       
            cnt = cnt + 1
            rs.movenext
           
        Wend
       
    rowCount = cnt
    End If
    Set rs = Nothing
   
End Function

No comments: