Solved

Reading from one column in a Dataset

Posted on 2006-06-30
2
197 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 500 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
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…

628 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