jump to navigation

Online Examination System Project in ASP.NET July 11, 2008

Posted by tuse in : ASP.NET, Databases , 122 comments

This is a project we made in ASP.NET. Its an examination system made in Visual Studio 2008 using a MySQL database. Please do take a look at it and suggest improvements. Also, if the project is vulnerable to any security threats, please do ping us back.

I hope you will like our attempt at coding this application.

Features-

User first needs to supply valid credentials to begin the test.

Randomly chooses 5 questions from a database of 10 questions.

The test is a timed test, admin can change the duration of the test before it begins in the code.

Test-taker can leave a question un-answered and come back to the question (if time permits) using the ‘Previous’ and ‘Next’ Buttons.

Code Details-

1. Login is authenticated against a MySQL database.

2. AJAX is used for the timer, allowing only the timer label to postback to the server each second.

3. Use of the Random class to generate 5 questions out of the 10 in the database.

4. Session Management using Cookies and Session Variables.

5. Use of javascript in the master-page to prevent the ‘Back’ navigation from a page (clearing the cache)  [Would love your suggestions on an alternative to this]

6. Once the 5 questions are chosen randomly, they are held in a DataTable. This is then held in a  Session Variable to hold the values during postbacks.

Get the project here

Get the database here

Connecting MySQL with .NET - Revisited July 6, 2008

Posted by prasu in : Databases, Tips and Tricks , 1 comment so far

Today, I came across another way to connect to a MySQL database in .NET

This is done through MySQL Connector/Net (We are using v 5.1.6)

MySQL Connector provides a namespace ‘MySql.Data.MySqlClient’ which gives you objects such as-

MySqlConnection - To establish a connection

MySqlCommand- Specify the MySQL Command

MySqlDataAdapter- Form the link between the dataset and the database

In order to be able to use these objects, you must first download the Connector from the MySQL website here

Therafter, in order to use this in your VB.NET Project, goto Project Menu -> Add Reference -> Under the .NET tab, Select MySQL.Data

You will need an import statement too as shown in the snippet that follows.
The connection string in this case would change to-


Server=127.0.0.1;Uid=<username>;Pwd=<password>;Database=<database name>;

Read the Documentation here

One difference that is worthy of mention is the manner in which a parameterized query is constructed. It differs from the type we used earlier for ODBC. Here is a small snippet to illustrate the same-

Imports MySql.Data.MySqlClient

Dim cn As New MySqlConnection(" Server=127.0.0.1;Uid=root;Pwd=;Database=logindb;")
        Dim cmd As New MySqlCommand("select * from login where username=?user and password=?pass", cn)
        cmd.Parameters.Add("?username", MySqlDbType.VarChar, 80).Value = Me.TextBox1.Text
        cmd.Parameters.Add("?pass", MySqlDbType.VarChar, 80).Value = Me.TextBox2.Text
        Dim ds As New DataSet
        Dim adp As New MySqlDataAdapter(cmd)
        adp.Fill(ds, "login")
        Me.DataGridView1.DataSource = ds
        Me.DataGridView1.DataMember = "login"


Warning: stristr() [function.stristr]: Empty delimiter in /home/tekyt17/public_html/dotnet/wp-content/plugins/wassup/wassup.php on line 2093