Beyler onlinesınav portalı projem var.Ekrana sadece 4 soru getirebiliyorum veritabanından.İleri butonuna bastıgımda 5 konumunda satır yok hatası alıyorum.Bilen biri yardımcı olursa çok sevinirim.Projeyi tamamlamam için son gunum
Imports System.Data.OleDb
Public Class sinav Inherits System.Web.UI.Page Dim count As Integer Dim ans As String Dim a(4), t As Integer Dim adp As New OleDbDataAdapter Dim ds As New DataSet Dim ctr As Integer Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & HttpContext.Current.Server.MapPath("App_Data/data.mdb")) Dim zaman As DateTime Dim cmd As New OleDbCommand Dim dt As New DataTable Dim dr As DataRow Sub Show()
Dim v As View = Me.View1 dt = Session("Cevaplar") Dim l As Label l = CType(v.FindControl("Label1"), Label) l.Text = dt.Rows(ctr).Item("soruid") & "." l = CType(v.FindControl("Label2"), Label) l.Text = dt.Rows(ctr).Item("sorubaslik")
Dim r As RadioButtonList r = CType(v.FindControl("RadioButtonList1"), RadioButtonList) r.Items.Clear() r.Items.Add(dt.Rows(ctr).Item("cevapa")) r.Items.Add(dt.Rows(ctr).Item("cevapb")) r.Items.Add(dt.Rows(ctr).Item("cevapc")) r.Items.Add(dt.Rows(ctr).Item("cevapd")) r.SelectedIndex = dt.Rows(ctr).Item("secilen") Session("ctr") = ctr End Sub Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs) Handles Timer1.Tick Dim suan As DateTime = Now Dim kalanzaman As DateTime Try kalanzaman = (zaman - suan).ToString Me.Label5.Text = "Kalan Zaman: " & kalanzaman.ToShortTimeString Catch ex As Exception Me.Label5.Text = "Zaman Ayarı Bozuk.Yönetici ile İletişime Geçiniz!" End Try If kalanzaman.ToShortTimeString = "00:00:00" Then Dim puan As Integer dt = Session("Cevaplar") For Each x In dt.Rows If x("secilen") + 1 = x("dogrucevap") Then puan += 1 End If Next Response.Redirect("sonuc.aspx?puan=" & puan) End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then Me.MultiView1.ActiveViewIndex = 0 cnn.Open() cmd.Connection = cnn
Dim arbit As New Random Randomize()
X: For i = 0 To a.GetUpperBound(0) t = arbit.Next(1, 10)
If Array.IndexOf(a, t) = -1 Then a(i) = t
Else GoTo X End If
Next For i = 0 To 4 cmd.CommandText = "select * from sorular where soruid=" & a(i) adp.SelectCommand = cmd adp.Fill(ds, "sorular") Next
For Each r In ds.Tables("sorular").Rows dr = dt.NewRow dr("soruid") = dt.Rows.Count + 1 dr("sorubaslik") = r.Item("sorubaslik") dr("cevapa") = r.Item("cevapa") dr("cevapb") = r.Item("cevapb") dr("cevapc") = r.Item("cevapc") dr("cevapd") = r.Item("cevapd") dr("dogrucevap") = r.Item("dogrucevap") dr("secilen") = -1 dt.Rows.Add(dr)
Next
Session("Cevaplar") = dt
Call Show()
End If End Sub
Protected Sub btnileri_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnileri.Click ctr = Session("ctr") dt = Session("Cevaplar") Session("ctr") = ctr ctr += 1 Show() If ctr = 9 Then Me.btnileri.Enabled = False
End If Me.btnGeri.Enabled = True End Sub
Protected Sub btnGeri_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnGeri.Click ctr = Session("ctr") dt = Session("Cevaplar") ctr = ctr - 1 If ctr = 0 Then Me.btnGeri.Enabled = False
End If Session("ctr") = ctr Me.btnileri.Enabled = True Show() End Sub
Protected Sub RadioButtonList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles RadioButtonList1.SelectedIndexChanged dt = Session("Cevaplar") For Each drow In dt.Rows If drow("soruid") = Me.Label1.Text Then drow("secilen") = Me.RadioButtonList1.SelectedIndex Exit For
End If Next
Session("Cevaplar") = dt
End Sub
Protected Sub btnPuan_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnPuan.Click Dim puan As Integer dt = Session("Cevaplar")
For Each x In dt.Rows If x("secilen") + 1 = x("dogrucevap") Then puan += 1
End If Next Response.Redirect("sonuc.aspx?puan=" & puan) End Sub