Solved

VB.Net - DataRow Declartion Assistance

Posted on 2012-12-31
3
477 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 500 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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