?
Solved

Returning One row from TableAdapter

Posted on 2007-11-28
2
Medium Priority
?
1,155 Views
Last Modified: 2009-07-29
I have created a table adapter that returns one row (selec top 1 ....)

In my Page_Load function, I want to take that value and put it in a label.

        Dim IAdapter As New IDataSetTableAdapters.Member1TableAdapter()
        Dim members As IDataSet.Member1DataTable

        members = IAdapter.GetNumberMembers

        For Each member1Row As IDataSet.Member1Row In members
            LabelNumMembers.Text = FormatNumber(member1Row.m_id, 0)
        Next

    End Sub

How do I convert the "For Each" properly for just one row?

And am I doing the above correctly? It works, so I know it ain't broke. But maybe it's misguided and could be improved?

thanks.
0
Comment
Question by:Starr Duskk
[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
2 Comments
 
LVL 8

Accepted Solution

by:
Thejaka earned 2000 total points
ID: 20370895
There's really nothing wrong in using For Each, but if you insist...

If members.Rows.Count > 0
  LabelNumMembers.Text = FormatNumber(members(0).m_id, 0)
End If

Open in new window

0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20373197
thanks!!! yay! shiney!

0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 18 hours left to enroll

770 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