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.
Online Test Application Help.
Started by sat147, Sep 19 2009 06:56 AM
12 replies to this topic
#1
Posted 19 September 2009 - 06:56 AM
|
|
|
#2
Posted 19 September 2009 - 07:00 AM
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
Posted 19 September 2009 - 07:01 AM
Maybe we can chat. my id is mr_skyflakes21 (Yahoo Messenger)
#4
Posted 19 September 2009 - 07:02 AM
ya it's data table
#5
Posted 19 September 2009 - 07:08 AM
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?
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
Posted 19 September 2009 - 07:16 AM
Exactly,
yes i have that table "tbl_onlinetest".
in which i have same fields that u mentioned.
yes i have that table "tbl_onlinetest".
in which i have same fields that u mentioned.
#7
Posted 19 September 2009 - 07:21 AM
did you already know how to access it programmatically using c#?
#8
Posted 19 September 2009 - 07:24 AM
no buddy
i am trying it.but i am confused
i am trying it.but i am confused
#9
Posted 19 September 2009 - 07:31 AM
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?
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
Posted 19 September 2009 - 07:37 AM
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!.
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
Posted 19 September 2009 - 07:43 AM
i done that this is not issue
please tell me the actual process for my test
please tell me the actual process for my test
#12
Posted 19 September 2009 - 07:45 AM
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.
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.


Sign In
Create Account

Back to top









