Solved

System.IndexOutOfRangeException: There is no row at position 0.

Posted on 2006-11-22
8
381 Views
Last Modified: 2012-06-27
I have the following code  and when i traced the value for objDataSet.Tables.Count returns 1 and then errors out at the nextline (ie odr = objDataSet.Tables(0).Rows(0)
)

WHat could be the issue.

Here is the code snippet

        Dim objDAL As New MECDAL
        Dim objEntity As New MECEntity
        Dim objDataSet As DataSet
        Dim odr As DataRow
        objDataSet = objMECDAL.RetrieveMECGroups(lMECGroupID)
        If objDataSet.Tables.Count > 0 Then

            odr = objDataSet.Tables(0).Rows(0)

   .....

end if

0
Comment
Question by:GSK_DEV
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
8 Comments
 
LVL 10

Expert Comment

by:Kinger247
ID: 17998408
It returns 1 table (even if empty).
0
 
LVL 10

Accepted Solution

by:
Kinger247 earned 250 total points
ID: 17998410
check for objDataSet.Tables(0).Rows.count instead.
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
ID: 17998700
Check this way:

    If objDataSet.Tables.Count > 0 AndAlso objDataSet.Tables(0).Rows.Count > 0 Then

The 'AndAlso' operator is a shortcut logical operator that if the first expression isn't True, the second part isn't evaluated.

Bob
0
 
LVL 10

Expert Comment

by:Kinger247
ID: 18015931
Hi GSK_DEV, did this work for you ?
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 18208065
You need to check for both conditions to be safe.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

707 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