Jump to content

Online Test Application Help.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
12 replies to this topic

#1
sat147

sat147

    Newbie

  • Members
  • Pip
  • 5 posts
hello,
i am creating online test in windows application using c#.net.
i have table that contains Questions and its options also some other filed.
different questions having different options i.e some of them having 2 options,some of them having 4 etc.
so i want to display that question 1 with it's option in radioButtons .
question 2 with it's option in radioButtons and so on...
also having next previous buttons on form.
please help.If possible explain with code.

--Sanjay.

#2
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
What is this table? Because it can be a table of a database. Enlighten me so i can help you with the best i can.

#3
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Maybe we can chat. my id is mr_skyflakes21 (Yahoo Messenger)

#4
sat147

sat147

    Newbie

  • Members
  • Pip
  • 5 posts
ya it's data table

#5
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Ok clear me if im wrong, You have Question table, with fields TableQuestions and TableAnswers?. You have said earlier that some of you question were not more that two but with a maximum of 4 right?

Maybe, you can declare In the table
in column1: ID (its the primary key right?)
in column2: Question with an attribute of string
in column3 - 7: Choice1 - Choice4 ( where in if you have two choices dont worry, you can just fill up the two columns, in this case choice1 and choice2)

in column8: finally, the Answer field where in you will list down all the answer so you woul have a basis for checking. Alrighty?

#6
sat147

sat147

    Newbie

  • Members
  • Pip
  • 5 posts
Exactly,
yes i have that table "tbl_onlinetest".
in which i have same fields that u mentioned.

#7
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
did you already know how to access it programmatically using c#?

#8
sat147

sat147

    Newbie

  • Members
  • Pip
  • 5 posts
no buddy
i am trying it.but i am confused

#9
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Ok, what database are you using? MSAccess?

I know a little bit about MSAccess, Since SQL Sytanx is pretty universal, meaning they are the same in any kind of database mediums.

for now, i will do the best i can to help you.

First things first;
importing libraries are the most important procedure.

using System.Data.OleDB; // this initialize library of Database(or whatever it is)

OleDbConnectionStringBuilder ocsb; //a string builder to avoid confusion;
OleDbConnection conn; //this initializes the connection between you and the database;
OleDbCommand cmd; //command builder such as(SELECT * FROM Questions);
OleDbDataReader reader; //Reads certain data from the table;

ocsb = new OleDbConnectionStringBuilder();
ocsb["Provider"] = "Microsoft.Jet.OLEDB.4.0";
ocsb["Data Source"] = "C:/SampleDB.MDB";//directory of your database. For easeness, put you database in C:/;

Ok now you may ask. Ah,,ok so how would we access it?

#10
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
To access a file or anything you must have a connection.
In the declarations in the top you will see the "OleDBConnection conn"

That instantiates the connection.

to initialize it, we provide information about it. with the use of "
OleDbConnectionStringBuilder ocsb" . Fields like provider, data source.

Next we open the connection.
This can be done by:

conn.Open(); //opens the connection;

Tada! The connection is open.

Now, what are we going to do? Access the database right?
Here comes the commands.

Commands are basic requirement in SQL programming.

SQL is a Standard - BUT....

Although SQL is an ANSI (American National Standards Institute) standard, there are many different versions of the SQL language.

However, to be compliant with the ANSI standard, they all support at least the major commands (such as SELECT, UPDATE, DELETE, INSERT, WHERE) in a similar manner.

Note: Most of the SQL database programs also have their own proprietary extensions in addition to the SQL standard! (TAKEN FROM w3shools.com) credit goes to them!.

#11
sat147

sat147

    Newbie

  • Members
  • Pip
  • 5 posts
i done that this is not issue
please tell me the actual process for my test

#12
mr_skyflakes21

mr_skyflakes21

    Learning Programmer

  • Members
  • PipPipPip
  • 54 posts
Next, we have to retrieve something right?

For now, since you have prepared questions, we dont have to user UPDATE, DELETE and INSERT.

SQL Syntax is NOT case sensitive! I repeat, NOT!

To retrieve the data from you table, we will use SELECT.

You must Store it somewhere in your Code!A variable or a class right?
To make it easy, Make a Question Class that has the attribute same as your field names in table,

You can see the OleDbCommand cmd at the top right?
Thats what we are going to use.

Basic Syntax of OleDBCommand;

OleDBCommand command = new OleDBCommand(string query, OleDBConnection conn);

so, we will create a string of command! same as the syntax when you use SQL!.

string selectCommand = "SELECT * FROM table_name";//commmand

then, we will apply it.

command = new OleDBCommand(selectCommand, conn);

command's counterpart is also know as Queries.