Did sql query fetch some result??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mclueless
    New Member
    • Jan 2008
    • 56

    Did sql query fetch some result??

    I am working with VB6 and Access. I am using ADODB. when i set a reordset and run a sql query then how do i check if the query has fetched some result or no??

    eg. I have a query as follows:

    rs.open "SELECT * FROM Invoice_Master WHERE Inv_No=" & val(txtInvNo.te xt) & "",con,3,3

    and now i wish to know if the invoice no mentioned in the textbox was found in the table or no then how do i do that??
  • lotus18
    Contributor
    • Nov 2007
    • 865

    #2
    Originally posted by mclueless
    I am working with VB6 and Access. I am using ADODB. when i set a reordset and run a sql query then how do i check if the query has fetched some result or no??

    eg. I have a query as follows:

    rs.open "SELECT * FROM Invoice_Master WHERE Inv_No=" & val(txtInvNo.te xt) & "",con,3,3

    and now i wish to know if the invoice no mentioned in the textbox was found in the table or no then how do i do that??
    [code=vb]rs.open "SELECT * FROM Invoice_Master WHERE Inv_No=" & val(txtInvNo.te xt),con,3,3

    If Not (rs.BOF And rs.EOF) then
    Msgbox "Inv_No Found"
    else
    Msgbox "Inv_No Not Found"
    End If
    [/code]

    Rey Sean

    Comment

    • mclueless
      New Member
      • Jan 2008
      • 56

      #3
      Thanks a tonnnnnnn...... ......

      Comment

      • daniel aristidou
        Contributor
        • Aug 2007
        • 494

        #4
        You could also use the count method
        [CODE=vb]if rs.count = 0 then
        MsgBox("No Results")
        Else
        MsgBox(rs.count & " Results Where Found")
        End if
        [/CODE]

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Originally posted by daniel aristidou
          You could also use the count method ...
          Wouldn't it be RecordCount? (I'm not familiar with ADODB)

          Comment

          • daniel aristidou
            Contributor
            • Aug 2007
            • 494

            #6
            Originally posted by Killer42
            Wouldn't it be RecordCount? (I'm not familiar with ADODB)
            Probably.... i'm not very familiar with vb6 anymore (i still can use it though) ......in vb08 ...you have so many snippets

            Comment

            • lotus18
              Contributor
              • Nov 2007
              • 865

              #7
              Originally posted by Killer42
              Wouldn't it be RecordCount? (I'm not familiar with ADODB)
              Yes, it should be RecordCount.

              Comment

              Working...