• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1160
  • Last Modified:

Returning One row from TableAdapter

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
Starr Duskk
Asked:
Starr Duskk
1 Solution
 
ThejakaCommented:
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
 
Starr DuskkASP.NET VB.NET DeveloperAuthor Commented:
thanks!!! yay! shiney!

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now