TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Stella Bloom
NA
17
1.3k
i want to match the radiobutton options with C# sql
Jul 26 2017 2:55 PM
i want to match the radiobutton options with correct ans in data base but what i did is
its just giving right for wrong, and viceversa
private void answer()
{
string Answer;
int score = 0;
SqlConnection con = new SqlConnection();
string cmd2= "SELECT Answer FROM Questions
con.ConnectionString = constring;
SqlCommand cmdn = new SqlCommand(cmd2, con);
//SqlDataAdapter sda = new SqlDataAdapter(cmd2, conn);
try
{
con.Open();
SqlDataAdapter sda = new SqlDataAdapter(cmd2, con);
DataTable dtb = new DataTable();
SqlDataReader Reader = cmdn.ExecuteReader();
if (radioButton1.Checked == true)
{
Answer = radioButton1.Text;
radioButton1.Checked = false;
}
else if (radioButton2.Checked == true)
{
Answer = radioButton2.Text;
radioButton2.Checked = false;
}
else if (radioButton3.Checked == true)
{
Answer = radioButton3.Text;
radioButton3.Checked = false;
}
else if (radioButton4.Checked == true)
{
Answer = radioButton4.Text;
radioButton4.Checked = false;
}
else { Answer = ""; }
if (Answer == label3.Text)
{
MessageBox.Show("your answer is correct");
}
else
{
MessageBox.Show("your answer in incorrect");
Reply
Answers (
2
)
How to create quiz application with timer in C#.net
Sum of Datagridview.