hi i am working in asp.net with vb
I have a webform for displaying questions and their options. For that I have 5 textboxes for displaying answers(options) and corresponding checkboxes for user click and a linkbutton for navigation. I have 20 questions in my database. After attending all the questions when I click a mark button there must display in a label number of correct answers.
That if I click for question1 option b as correct answer,which is true in the database, my first answer is correct. Then for question2 I answered option c as correct but actually it is not the right answer when compared to database, then no counting. Like that I answered all the 20 questions and last I clicked mark button then a label must show “You answered 12 correct answers out of 20”(if I answered 12 correct answers,if it is 11 label should display like “11 correct answers”). Then in another label percentage should be calculated as, if correct answers are 12 then (12/20)*100. Plz help me. How can I do this.
my code is as follows Sub getanswer(ByVal qno As Integer) opt = Session("option".ToString) Dim con As New SqlConnection("server=SYSTEM4;uid=sa;pwd=;database=examination") con.Open() Select Case opt Case "ca"
Dim cmd As New SqlCommand("select ca from inques where qno=" & qno, con) Dim drd As SqlDataReader drd = cmd.ExecuteReader drd.Read()
If drd(0).ToString = "True" Then ctr = total + 1 Else ctr = 0 End If
Case "cb"
Dim cmd As New SqlCommand("select cb from inques where qno=" & qno, con) Dim drd As SqlDataReader drd = cmd.ExecuteReader drd.Read()
If drd(0).ToString = "True" Then
ctr = ctr + 1 Else
ctr = 0 End If
Case "cc"
Dim cmd As New SqlCommand("select cc from inques where qno=" & qno, con) Dim drd As SqlDataReader drd = cmd.ExecuteReader drd.Read()
If drd(0).ToString = "True" Then
ctr = ctr + 1 Else
ctr = 0 End If
Case "cd"
Dim cmd As New SqlCommand("select cd from inques where qno=" & qno, con) Dim drd As SqlDataReader drd = cmd.ExecuteReader drd.Read()
If drd(0).ToString = "True" Then
ctr = ctr + 1 Else
ctr = 0 End If
Case "ce"
Dim cmd As New SqlCommand("select ce from inques where qno=" & qno, con) Dim drd As SqlDataReader drd = cmd.ExecuteReader drd.Read()
If drd(0).ToString = "True" Then
ctr = ctr + 1 Else
ctr = 0 End If
in next button getanswer(txtno.text)
in mark button click txtpercent.text=ctr
pls correct the code
regards
|
| Author: syed 26 Jun 2007 | Member Level: Silver | Rating: Points: 2 |
hi aparna did not went through your long letter,explain in 2 to 3 lines.
|
| Author: Aparna.U 26 Jun 2007 | Member Level: Gold | Rating: Points: 2 |
i want to display the total number of correct answers in a label when i click a button in asp.net with vb
|
| Author: syed 26 Jun 2007 | Member Level: Silver | Rating: Points: 2 |
i dont know how is your db design. 1)from the page1 take a counter if he aswers correct increment the counter and at the end u have how many questions he has answered
|