?
Solved

Moving to Next Row in DataSet with Criteria

Posted on 2011-03-25
8
Medium Priority
?
292 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 2000 total points
ID: 35219979
That way you cannot jump ... you need to check the value and decide :(
0
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!

 

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

Industry Leaders: 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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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