Solved

VB.Net - DataRow Declartion Assistance

Posted on 2012-12-31
3
475 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
3 Comments
 
LVL 142

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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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 tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

809 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