Public Class quiz Inherits System.Web.UI.Page Public CMD As New OleDbCommand Public CMDB As New OleDbCommandBuilder Dim da As OleDb.OleDbDataAdapter Dim con As New OleDb.OleDbConnection Dim sql As String Public ds As New DataSet Public Info As New DataTable Dim i As Integer = 0 Dim scor As Integer = 0 Dim ans As String Dim corect As String Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|learn_english.mdb" con.Open() sql = "SELECT TOP 5 * FROM quiz where level= 1 ORDER BY Rnd(-10000000*TimeValue(Now())*[id]) " da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds) Label1.Text = ds.Tables(0).Rows(0).Item(1).ToString() RadioButton1.Text = ds.Tables(0).Rows(0).Item(2).ToString() RadioButton2.Text = ds.Tables(0).Rows(0).Item(3).ToString() RadioButton3.Text = ds.Tables(0).Rows(0).Item(4).ToString() RadioButton4.Text = ds.Tables(0).Rows(0).Item(5).ToString() End If End Sub Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Label3.Text = "choese Ansewer" corect = ds.Tables(0).Rows(i).Item(6).ToString() If RadioButton1.Checked = True Then ans = RadioButton1.Text ElseIf RadioButton2.Checked = True Then ans = RadioButton2.Text ElseIf RadioButton3.Checked = True Then ans = RadioButton3.Text ElseIf RadioButton4.Checked = True Then ans = RadioButton4.Text Else Label3.Text = "choese Ansewer" End If If ans = corect Then scor = scor + 10 End If If i < 4 Then i = i + 1 Label1.Text = ds.Tables(0).Rows(i).Item(1).ToString() RadioButton1.Text = ds.Tables(0).Rows(i).Item(2).ToString() RadioButton2.Text = ds.Tables(0).Rows(i).Item(3).ToString() RadioButton3.Text = ds.Tables(0).Rows(i).Item(4).ToString() RadioButton4.Text = ds.Tables(0).Rows(i).Item(5).ToString() con.Close() Else MultiView1.ActiveViewIndex = 1 Label2.Text = "your scor is " + scor.ToString() End If End Sub End Class
If ds.Tables(0) Is Nothing OrElse ds.Tables(0).Rows.Count = 0 Then 'is really empty Else 'You have a dataset with data. End If
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)