Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB.Net - DataRow Declartion Assistance

Posted on 2012-12-31
3
Medium Priority
?
483 Views
Last Modified: 2012-12-31
Good Day Experts!

I am looking for assistance with my DataRow declaration.  Right now I have it declared in my For Next Loop:

For Each sqlRSGetProcessing As DataRow In sqlRStbl.Rows

Next

This works great with no issues.  After the Next, I am trying to reference the DataRow in a line of code for a messageBox in event there is an error.  However,  it tells me the DataRow is not declared.

So, up above the For statement I declare it.  That makes the issue about it not being delcared go away in my code for the messageBox.  But the "For Each sqlRSGetProcessing As DataRow In sqlRStbl.Rows" line barks at me saying the DataRow is alread delcared.

How can I make the DataRow in the For statement visible to the code below it?

Thanks,
jimbo99999
0
Comment
Question by:Jimbo99999
[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 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 38732708
this should work:
Declare sqlRSGetProcessing As DataRow 
For Each sqlRSGetProcessing In sqlRStbl.Rows
Next

Open in new window

0
 
LVL 17

Expert Comment

by:nepaluz
ID: 38732746
The above answer should address your query, however it will contain the last row in the table, whereas the error you want to notify of may indeed be in another row within the table. In which case, stick to your original code and simply handle your messagebox inside a try catch, e.g
        For Each sqlRSGetProcessing As DataRow In sqlRStbl.Rows
            Try
                'here do your processing
            Catch ex As Exception
                'here put your messagebox
            End Try
        Next

Open in new window

0
 

Author Closing Comment

by:Jimbo99999
ID: 38732758
Excellent...I would have been staring at my For Each line not realizing the answer was right there.

Thanks,
jimbo99999
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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