5
Contributors
6
Replies
11
Views
8 Years
Discussion Span
Last Post by _V_
0

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.

0

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

0

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);

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.EndExecuteReader();

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

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

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:

try
            {
                objConnection.Open();
                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”);

			}
                        objDataReader.Close();
                        objConnection.Close();
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.