Results 1 to 6 of 6

Thread: select statement

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    138

    select statement

    Hi gurus

    new to all this as can see on my previous threads.

    I would like to check if a select statement return or does not return any result, I can get the select statement no problem but how do I go checking if there is or there is not any results returned

    Thanks a bunch

  2. #2
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,950

    Re: select statement

    Case has an 'Else' construct.
    Code:
            Select Case xyz
                Case 1
                    'Do something
                Case 2
                    'Do Something else
                Case Else
                    'Some other value was returned
            End Select

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Mar 2001
    Posts
    138

    Re: select statement(MOVED)

    Thanks Bulldog

    I am really sorry for not been more specific, what I meant with select statement was sql select statement, again I am sorry to have wasted your time this way.
    Last edited by GUARO; May 26th, 2007 at 07:06 AM. Reason: WRONG FORUM

  4. #4
    Addicted Member Genom's Avatar
    Join Date
    May 2006
    Posts
    186

    Re: select statement

    umm you can try to open that SQL statement with RecordSet and transport it to a dataset as a table. And check what is in in that table or you can check errors too.
    Dim Me As Coder

  5. #5
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: select statement

    I think there are as many ways to do this as there are queries. If you are using a datareader (ExecuteReader), then you can look at the HasRows property. If you are getting a single value (ExecuteScalar), then you can look at the return value. I suspect there is something like this for all options, and which one you choose depends not on the SQL statement, but on what you are doing with the SQL statement.
    My usual boring signature: Nothing

  6. #6
    Member
    Join Date
    Aug 2006
    Posts
    46

    Re: select statement

    I think you are looking for code like this after u excute ur select statment

    Code:
    Dim Dr as datareader
    Dr = cmd.excutereader
    
    if dr.hasrows = false then
    
     ' Do what u wanna do here if u don't get results
    else
     ' Do what u wanna do here if u get results
    
    end if

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width