Using a dataset in a conditional statement

Posted on 2004-11-24
Last Modified: 2010-04-23
Is this possible?  For example, I have a dataset that grabs data from a OBDC connection using a SQL query.  Is there a way to use the dataset to in a IF statement?  If so what is the syntax?  If not, then how would I go about using data from a data source in a conditional statement?  

Sorry if this is a novice question, I am a novice VB user afterall.  I browsed around and couldn't quite find a solution.  Thanks!  

Question by:vangmoua

    Author Comment

    Oh yeah, as you might guess, the dataset contains multiple fields and I need to compare one of those fields in the conditional statement.  
    LVL 24

    Expert Comment

    by:Jeff Certain
    Please explain the question a little better...

    Once you get the populate the datset, you can easily compare the value of one of the fields...

    dataset.Tables(0).Rows(i).Item("fieldName") will give you the entry in <fieldname> for the ith row. You can also iterate through these, use the dataview object's rowfilter method to filter a table, etc.
    LVL 24

    Accepted Solution

    oh yeah...

    if integer.parse(dataset.Tables(0).Rows(i).Item("fieldName")) > value then

    end if

    will cast the entry in the field to an integer (similar syntax for dates, single, etc) and do the comparison

    Author Comment

    Thanks!  That's exactly what I was looking for.  I couldn't find that syntax.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    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…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…

    759 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