السلام عليكم ور حمة الله وبركاته
مشكلة كودي أنه الى قبل ساعة كان يضيف في الداتابيس والحين صار مايضيف ما أدري وين المشكلة
مع اني ماغيرت ولاشي
الكود:
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim con As New OleDbConnection
con.ConnectionString = "provider =microsoft.jet.oledb.4.0;data source=c:\CBL\CBLDB.mdb"
'retrive questions from database depend on exam
Dim i As Integer
con.Open()
If exam = 9 Then
Dim st As String = "select * from student"
Dim studn(20) As String
Dim studp(20) As String
Dim coms As OleDbCommand
coms = New OleDbCommand(st, con)
Dim rs As OleDbDataReader
rs = coms.ExecuteReader
Dim k1 As Integer = 0
While rs.Read
studn(i) = rs.GetValue(1)
studp(i) = rs.GetValue(2)
If n <> studn(i) Then
If spass <> studp(i) Then
i = i + 1
Else
i = i + 1
End If
ElseIf n = studn(i) And spass = studp(i) Then
k1 = k1 + 1
TextBox4.Text = rs.GetValue(0)
Exit While
End If
End While
TextBox2.Text = Date.Today
TextBox1.Text = "chapter 1"
'TextBox3.Text = result.ToString
con.Close()
If k1 > 0 Then
Try
Dim w As New OleDbCommand
w.Connection = con
w.CommandType = CommandType.Text
w.CommandText = "INSERT INTO exam(etype,edate,grade,SID)" & _
"values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "')"
con.Open()
w.ExecuteNonQuery()
con.Close()
MsgBox("تمت الإضافة بنجاح ")
Catch ex As Exception
Exit Sub
End Try
End If
End If
End Sub