Determine if any records are returned

Posted on 2006-03-24
Last Modified: 2010-04-23
If want to use the following to return a group of records from an access database.  How would i determine if any records were returned or not?

 Dim cn As New OleDbConnection(Global_Values.strConn)
        Dim cmd As New OleDbCommand(sSQL, cn)
        Dim dr As OleDbDataReader

        If cn.State = Data.ConnectionState.Closed Then
        End If

        dr = cmd.ExecuteReader
Question by:Mike_Stevens
    LVL 35

    Expert Comment

    While dr.Read

    End while
    LVL 35

    Accepted Solution


    if dr.HasRows then

    end if
    LVL 28

    Expert Comment

    or even

    if dr.ReadI() then

    end if

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now