ช่วยดูให้หน่อยค่ะว่ามันผิดตรงไหน
พอดีจะเขียนโปรแกรมเก็บข้อมูลนักเรียนค่ะ เลยเขียนตามในหนังสือ VB6.ฉบับฐานข้อมูล โดยใช้ADODC กับฐานข้อมูลจากAccess2003 แต่พอรันแล้วมันเออเรอร์ค่ะ
Dim NewRecord As Boolean
Private Sub Adodc1_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset) Dim adoMsg As String With Adodc1.Recordset adoMsg = .AbsolutePosition& "/"&.RecordCount End With Adodc1.Caption = adoMsg
End Sub
Private Sub Command1_Click() NewRecord = True Adodc1.Recordset.AddNew Command1.Enabled = False Command2.Enabled = False Adodc1.Enabled = False End Sub
Private Sub Command2_Click() With Adodc1.Recordset .Update If NewRecord = True Then .Requery .MoveLast End If NewRecord = False End With
Command1.Enabled = True Command3.Enabled = True Adodc1.Enabled = True
End Sub
Private Sub Command3_Click() Dim Student_Name As String Student_Name = "Are you want to delete student name" & Text2.Text&"?" If MsgBox(Student_Name, vbYesNo, "Question") = vbYes Then With Adodc1.Recordset .Delete .MoveNext If .EOF Then .MoveLast End With End If
End Sub
|