Run time error 3251 Current Recordset does not support updating, this may be a limitation of the provider, or of the selected Locktype

Friends, I have a VB application that is using Oracle backend database. My code is as below but returns the above error when I try to add data.Kindly assist.

Private Sub cmdsave_Click()
rs.AddNew
rs!ID = txtID.Text
rs!Name = txtNAME.Text
rs!GROUPID = txtGROUPID.Text
rs!DATERECEIVED = txtDATERECEIVED.Text
rs!MODEL = txtMODEL.Text
rs!SERIALNO = txtSERIALNO.Text
rs!CERTIFIEDBY = txtCERTIFIEDBY.Text
rs!PROCUREMENTOFFICER = txtPROCUREMENTOFFICER.Text
rs!RECIEVEDBY = txtRECIEVEDBY.Text
rs.Update
txtID.Text = ""
txtNAME.Text = ""
txtGROUPID.Text = ""
txtDATERECEIVED.Text = ""
txtMODEL.Text = ""
txtSERIALNO.Text = ""
txtCERTIFIEDBY.Text = ""
txtPROCUREMENTOFFICER.Text = ""
txtRECIEVEDBY.Text = ""

If rs.BOF <> True And rs.EOF <> True Then
rs.MoveLast
i = Val(rs!ID)
i = i + 1
txtID.Text = i
Else
txtID.Text = 1
End If
'cmdRefresh_Click
txtID.SetFocus
'deIT.rsrecieve.Update
End Sub
Private Sub Form_Load()
'txtNAME.SetFocus

End Sub

Dim i As Integer, j As Integer
cn.ConnectionString = "Provider=MSDAORA.1;Password=3389mine;User ID=system;Data Source=192.168.167.22;Persist Security Info=True"
cn.Open
rs.Open "select * from ITINVENTORY order by ID", cn, adOpenDynamic, adLockOptimistic
If rs.BOF <> True And rs.EOF <> True Then
rs.MoveLast
i = Val(rs!ID)
i = i + 1
txtID.Text = i
Else
txtID.Text = 1
End If

txtNAME.Text = ""

The first thing I notice is that the code from line 40 through 53 is not inside a sub or function, and appears never to execute. I also see no DIM statement for either cn or rs (maybe at the module level, or global?)

So, based on the code you posted, either your connection and recordset variables are never instantiated or opened, or you have variable scoping or typing issues.

If these are just excerpts or snippets then you need to give more context. Otherwise, we're just guessing.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.