• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

Moving to Next Row in DataSet with Criteria

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
JackW9653
Asked:
JackW9653
  • 5
  • 3
1 Solution
 
jpaulinoCommented:
You can use a DataView to filter the DataTable
0
 
JackW9653Author Commented:
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
 
jpaulinoCommented:
That way you cannot jump ... you need to check the value and decide :(
0
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!

 
JackW9653Author Commented:
So you would replace the dataset with a dataview?
0
 
JackW9653Author Commented:
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
 
jpaulinoCommented:
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
 
JackW9653Author Commented:
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
 
JackW9653Author Commented:
Used Dataview, Thanks. Sorry for the delay, forgot question was still open.

Jack
0

Featured Post

Independent Software Vendors: 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!

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now