Solved

VB.Net - DataRow Declartion Assistance

Posted on 2012-12-31
3
478 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

710 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