อยากให้ช่วยแนะนำหน่อยครับ VB6 กับ Access เพิ่มข้อมูล

ตามโค้ดครับ เกิด เออเร่อ  Current Recordset does not support updating. This may be limitation of the provider, or of the selected locked type.  

ช่วยชี้แนะทีครับ



Option Explicit
Dim Conn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim DS As ADODB.Recordset
Dim Statement As String
Dim SQLStmt As String

Private Sub Command1_Click()
Dim Txt As String
Set RS = New Recordset
Txt = Text1.Text
Statement = "SELECT * FROM Customer WHERE CId ='" & Txt & "'"
     RS.Open Statement, Conn
     'RS.MoveFirst
     If RS.BOF Then RS.AddNew  <<<< ---- เกิดเออเร่อจุดนี้ครับผม
     RS("CId") = Txt
     'RS.Field("field2") = txt2.Text
     RS.Update
     RS.Close
     RS.Open Statement, Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
End Sub

Private Sub Form_Load()
'Text1.Text = ""
'Timer1.Interval = 100
Set Conn = New ADODB.Connection
Set RS = New ADODB.Recordset
Conn.ConnectionString = _
        "Provider=Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=" & App.Path & "\Test.mdb;" & _
        "Persist Security Info=False"
        Conn.Open
    
    

SQLStmt = "SELECT * FROM Customer"
With RS
If .State = adStateOpen Then .Close
.ActiveConnection = Conn
.LockType = adLockOptimistic
.Open SQLStmt
End With
    
End Sub
แสดงความคิดเห็น
โปรดศึกษาและยอมรับนโยบายข้อมูลส่วนบุคคลก่อนเริ่มใช้งาน อ่านเพิ่มเติมได้ที่นี่