i need help to create website for online test using asp.net with c# coding..
it shld consists of question with multiple answer choices

Recommended Answers

All 6 Replies

It is Very Difficult to Help someone who has not Started something. but logically this means that you need to use a Wizard control and Record the selected Questions and at the end give the results of the Test.

thanks sir,, but i have already done with something.. only the thing is that i couldn't able to retrive question and answers from database.. am using sql server and trying to retrive using ado.net connection

I hope this is what you are looking for. This example gets data from a table row by row.

string conString = "Data Source=myServerAddress;Initial Catalog=myDataBase;User Id=myUsername;Password=myPassword";
            using (SqlConnection con = new SqlConnection(conString))
                string sql = "SELECT * FROM tbl";
                SqlCommand cmd = new SqlCommand(sql, con);

                    SqlDataReader reader = cmd.EndExecuteReader();

                    while (reader.Read())
                        // do something with row

                        // string q = (string)reader["ColumnName"];
                catch (SqlException ex)
                    // Catch exception

Don't forget to include the

using System.Data.SqlClient;

You might want to consider your architecture first and post function by function or method by method as you build it.

In any case, your best bet is to use a cookie/database architecture for the application. You can pass and store all the questions/answers/info/whatever in the users cookie and then compare your cookie to the database driven answer key. This would work great in a multple choice enviroment. If you wish to display a score, you could embed if statements on the final page.

A brief example:

                objDataReader = objCommand.ExecuteReader();
                while (objDataReader.Read() == true)
                    A1 = objDataReader["answer1"] as string;
                    A2 = objDataReader["answer2"] as string;

                    if ((cookie["answer1"] == A1) & (cookie["answer2"] == A2))
				Response.Write(“The answer is correct”);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.