Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Reading from one column in a Dataset

Posted on 2006-06-30
2
Medium Priority
?
199 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 2000 total points
ID: 17018259
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
ID: 17018339
Works great, thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

824 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