[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

VB.Net - DataTable One Row

Posted on 2013-02-01
3
Medium Priority
?
390 Views
Last Modified: 2013-02-01
Good Day Experts!

I have a DataTable only contains 1 record.  In the past, I have only used for each loop to process the DataTable.  

For Each sqlRS In sqlRStbl.Rows

Next

How can I just get the row from the DataTable?

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 41

Accepted Solution

by:
Kyle Abrahams earned 400 total points
ID: 38843710
if SqlRStbl.Rows.Count > 0 then  'ensure there is a row
     sqlRStbl.Rows(0)  (use [0] insead of (0) in C#)
else
    'WOULD HAVE THROWN AN ERROR.  REPORT IT.
end if
0
 
LVL 35

Assisted Solution

by:YZlat
YZlat earned 400 total points
ID: 38843848
does this loop give you errors?

For Each sqlRS In sqlRStbl.Rows

Next


It shouldn't. If it does, do like ged325 suggested:

Dim dr as DataRow
dr=sqlRStbl.NewRow()
If sqlRStbl.Rows.Count > 0 Then
      dr=sqlRStbl.Rows(0)
End If
 

Open in new window


I was not sure where you wanted to store the results so i used a DataRow
0
 

Author Comment

by:Jimbo99999
ID: 38843880
Thanks for replying. I was not getting an error with the loop.  I had always processed DataTables with a ForEach loop.  But this DataTable is only being populated with 1 row of data.  I just never knew how to interrogate the DataTable for only 1 row.

 This all stems from when I was using a DataReader that I couldn't close before calling a subroutine.  I passed the subroutine the connection string used by the DataReader and was trying to execute a DataReader on that same connection and was getting an error.  So, I converted the DataReader to a DataTable in the calling routine to alleviate the problem.  

Thanks for the help,
jimbo99999
0

Featured Post

Independent Software Vendors: 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 …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

649 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