Solved

Moving to Next Row in DataSet with Criteria

Posted on 2011-03-25
8
244 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
  • 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
 

Author Comment

by:JackW9653
ID: 35220001
So you would replace the dataset with a dataview?
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now