Solved

Moving to Next Row in DataSet with Criteria

Posted on 2011-03-25
8
289 Views
Last Modified: 2012-05-11
Hello Experts,

Under a specific set of conditions I need to move to the next "Core" question. In my dataset I get the question type as one of fields, there are only 2 values; "Core" or "Followup". So I want to skip all the "Followup" questions and find the next "Core".

Thanks in advance for any help;

JackW9653
0
Comment
Question by:JackW9653
[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
  • 5
  • 3
8 Comments
 
LVL 48

Expert Comment

by:jpaulino
ID: 35219918
You can use a DataView to filter the DataTable
0
 

Author Comment

by:JackW9653
ID: 35219949
Thanks for the quick reply jpaulino, but I'm iterating through the dataset using the following code:
If intRow < intRowCount - 1 Then
              intRow = intRow + 1
              strQuestion = myDSALL.Tables(0).Rows(intRow).Item("Q_Key").ToString()
        Else
            MessageBox.Show("You have reached the end")
        End If

Open in new window


A dataview wouldn't be applicable here. Thanks.
0
 
LVL 48

Accepted Solution

by:
jpaulino earned 500 total points
ID: 35219979
That way you cannot jump ... you need to check the value and decide :(
0
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 

Author Comment

by:JackW9653
ID: 35220001
So you would replace the dataset with a dataview?
0
 

Author Comment

by:JackW9653
ID: 35220061
Doesn't a dataview only work against a single table? Here is how I'm filling my dataset:

  Dim strSelect As String = "SELECT q.Q_Key, p.Question, p.Response, q.Q_Type, q.Q_Trigger, q.Q_Trigger_Value, q.Sequence " & _
            "FROM tblQuestionnaire q " & _
            "Left Join LookupIQ_QuestionPool p ON q.Q_Key = p.Q_Key " & _
            "WHERE q.Q_Name = 'SOB013' " & _
            "Order By Sequence"

            Dim sqlda As New SqlCeDataAdapter(strSelect, cn)

            sqlda.Fill(myDSALL, "tblQuestionnaire")
            If myDSALL.Tables(0).Rows.Count > 0 Then
                intRowCount = myDSALL.Tables(0).Rows.Count
                strQuestion = myDSALL.Tables(0).Rows(intRow).Item("Q_Key").ToString()
                strTrigger = myDSALL.Tables(0).Rows(intRow).Item("Q_Trigger").ToString()
                strTrigger = myDSALL.Tables(0).Rows(intRow).Item("Q_Trigger_Value").ToString()
            Else
                MsgBox("Question records not found!")
            End If
        Catch err As SqlCeException
            MsgBox("An error occurred in LoadAllQuestions - " & err.Message)
        Finally
            cn.Close()
        End Try

How can I use a  dataview here?
0
 
LVL 48

Expert Comment

by:jpaulino
ID: 35220243
Dataview allows you to filter a datatable and not replace it.

Do you know what you need before fill the dataset? You could just filter in the select statement
0
 

Author Comment

by:JackW9653
ID: 35220347
I'm using the  WHERE clause to get the right name and sequence. I've added a new section that specifies the Type = Core, and am debugging it now. Basically if the users response matches the criteria it goes in sequence, if not it fires a different Select that only looks at 'Core' questions.

What do you think?
0
 

Author Closing Comment

by:JackW9653
ID: 35462941
Used Dataview, Thanks. Sorry for the delay, forgot question was still open.

Jack
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

724 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