Check empty datarow

Posted on 2011-04-27
Last Modified: 2012-06-21
How can I check to see if in datatable is empty while looping in datatable?

For I as integer = 0 to mydatatable.rows.count - 1


Question by:VBdotnet2005
    LVL 10

    Expert Comment

    by:Asim Nazir
    Here it's:

    DataTable dt;

    If(dt != null and dt.Rows.Count>0)
    // Process. Looping etc.

    Author Comment

    sorry, I meant to skip an empty row.
    What I am trying to do is to loop through datatable. If any rows that is empty, then skip reading it.

    Author Comment

    the entry row.
    LVL 10

    Accepted Solution

    checking datarow for Empty can only be done by checking all the Row cell values.
    Say you have 3 cells in a datarow. You can check cell 1 as follows:

    if(Datatable.Rows[0][0] != null)
    // process here

    you can check other cels using AND in above if stmt.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    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…

    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

    10 Experts available now in Live!

    Get 1:1 Help Now