Im using VB6 & Microsoft Access 2003.
I cant seem to add records it says Error "3251" Current Recordset does not support updating. This may be limitation from the provider, or of the selected Locktype"
Here is the code that's troubling me.
And this is the moduleCode:Dim rsDataCust As ADODB.Recordset Dim DBConnectionCust As ADODB.Connection Private Sub CmdMain_Click() Unload Me FrmMain.Show End Sub Private Sub CmdNext_Click() WriteRecord MsgBox "Patient successfully added !", vbOKOnly txtCustId.Text = " " TxtCustName.Text = " " TxtCustPhone.Text = " " TxtCustAdd.Text = " " TxtCustLID.Text = " " TxtCustIC.Text = " " TxtCustAge.Text = " " End Sub Private Sub Form_Load() Dim rsData As ADODB.Recordset Set DBConnectionCust = LoadDatabase(App.Path & "\LoginTest.mdb") Set rsDataCust = DBConnectionCust.Execute("SELECT * FROM CUSTOMER") End Sub Public Sub WriteRecord() With rsDataCust .AddNew .Fields("cust_id") = txtCustId .Fields("cust_name") = TxtCustName .Fields("cust_phone") = TxtCustPhone .Fields("cust_add") = TxtCustAdd .Fields("cust_license") = TxtCustLID .Fields("cust_ic") = TxtCustIC .Fields("cust_age") = TxtCustAge .Update End With End Sub
Code:Public DBConnectionCust As ADODB.Connection Public Function LoadDatabase_Cust(ByVal DatabaseName As String, ByVal cust_id As Integer, ByVal cust_name As String, ByVal cust_add As String, ByVal cust_phone As Integer, ByVal cust_ic As Integer, ByVal cust_license As Integer, ByVal cust_age As Integer) As ADODB.Connection Dim ConnectionData_Cust As ADODB.Connection Set ConnectionData_Cust = New ADODB.Connection ConnectionData_Cust.Provider = "Microsoft.Jet.OLEDB.4.0" ConnectionData_Cust.ConnectionString = "Data Source = " & DatabaseName ConnectionData_Cust.CursorLocation = adUseClient ConnectionData_Cust.Open , cust_id, cust_name, cust_add, cust_phone, cust_ic, cust_license, cust_age, conn, adOpenDynamic, adLockOptimistic Set LoadDatabase_Cust = ConnectionData End Function




Reply With Quote