C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




counting the mark


Posted Date: 26 Jun 2007      Total Responses: 3

Posted By: Aparna.U       Member Level: Gold     Points: 2


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





Responses

Author: syed    26 Jun 2007Member Level: SilverRating:     Points: 2
hi aparna did not went through your long letter,explain in 2 to 3 lines.


Author: Aparna.U    26 Jun 2007Member Level: GoldRating:     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 2007Member Level: SilverRating:     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




Post Reply
You must Sign In to post a response.
Next : search based on date
Previous : payment gateway
Return to Discussion Forum
Post New Message
Category: ASP.NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

Help Desk

Contact Us    Privacy Policy    Terms Of Use