Solved

Reading from one column in a Dataset

Posted on 2006-06-30
2
191 Views
Last Modified: 2010-04-23
Hi all,

I have a Dataset in my app populated with 10 columns of data. I also have a ComboBox that contains all the names of the columns. What I am trying to achieve is, when a user selects a column name from the ComboBox my app should look at the data in my Dataset from the selected column only and try to find a predefined value. If not found then it should pop up a message box. If all data in the column does match the predefined value then a different message box pops up.

Can someone give me a code example of how to do this as I am having a bit of trouble trying to figure it out.

Many Thanks.
0
Comment
Question by:kiranboi
2 Comments
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
Comment Utility
From your description, this is what I came up with:

    Dim objPredefinedValue As Object = "Predefined Value"

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim intMatchesFound As Integer = 0

        For Each row As DataRow In dsDataset.Tables(0).Rows
            If row.Item(ComboBox1.SelectedValue) = objPredefinedValue Then intMatchesFound += 1
        Next

        If intMatchesFound = 0 Then : MsgBox("No match found")
        ElseIf intMatchesFound = dsDataset.Tables(0).Rows.Count Then : MsgBox("All rows match")
        Else : MsgBox(intMatchesFound & " matches found")
        End If
0
 

Author Comment

by:kiranboi
Comment Utility
Works great, thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

771 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now