Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Reading from one column in a Dataset

Posted on 2006-06-30
2
Medium Priority
?
198 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
[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 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

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.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

721 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