0

i have a dataset

Dim query1 As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM AnswerList WHERE SurveyID=83 AND QuestionNum='" & counter & "'", strConnection)
            Dim ds As New DataSet
            query1.Fill(ds)

how can i refer to specific column for example if i want to search for column QuestionNum=1 in table AnswerList
what i want to do is to perform specific action like this..
if QuestionNum=1 Then
****add controls here
Else if QuestionNum=2 Then
****another new controls here..
Else.....
.....
End if

can anyone tell me how to perform this?

3
Contributors
2
Replies
3
Views
10 Years
Discussion Span
Last Post by mushtaq_ilyas
0

please find one way of doing it with my understanding of your prob..


Dim query1 As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM AnswerList WHERE SurveyID=83 AND QuestionNum='" & counter & "'", strConnection)
Dim ds As New DataSet
query1.Fill(ds)
Dim dt As DataTable
Dim dr As DataRow
dt = ds.Tables(0) ' OR ds.Tables("AnswerList")
For Each dr In dt.Rows
If dr("QuestionNum") = 1 Then
'/****add controls here
ElseIf dr("QuestionNum") = 2 Then
'****another new controls here..
'Else.....
'.....
End If


Next

//do the needed casting if required

0

Dim query1 As SqlDataAdapter = New SqlDataAdapter("SELECT * FROM AnswerList WHERE SurveyID=83 AND QuestionNum='" & counter & "'", strConnection)
Dim ds As New DataSet
query1.Fill(ds)
int question=ds.tables[0].rows[0]["QuestionNum"].Tostring();
if(question==1)
{
control enabled logic goes here ...
}
else if (question==2)
{
control enabled logic goes here ...
}

hope this help you :)
cheeers

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.