Error inserting data into recordset with provider oraOLEDB

0

Good afternoon guys.

I have a problem with several applications here in the company that are in VB6 . When I try to include a record in a recordset an error occurs (it is described in the code), however it only happens when I use provider oraOLEDB . For MSDAORA it works normally. I set up an example to do the tests, basically with the instructions that are in the application. Home If anyone can help I thank you!

Private Sub Command1_Click()

Dim cnn  As New ADODB.Connection 
Dim sSql As String 
Dim Rst  As ADODB.Recordset 
Dim Cmd  As New ADODB.Command 

connection using oraOLEDB

sSql = "Provider=oraOLEDB.oracle.1; Password=**; User ID=USER_DB; " & _
"Data Source=ORA12C; Persist Security Info=false;"

Connection using MSDAORA

sSql = "Provider=MSDAORA; Password=**; User ID=USER_DB; " & _
"Data Source=ORA12C; Persist Security Info=false"

cnn.Open sSql 
cnn.CursorLocation = adUseClient 

sSql = "SELECT CODIGO, DESCRICAO FROM TABELA" 

Set Rst = New ADODB.Recordset 
Rst.Open sSql, cnn, adOpenStatic, adLockBatchOptimistic, adCmdText 

Corto a conexão para trabalhar como um recordset virtual. Depois monto a instrução DML.
Set Rst.ActiveConnection = Nothing

This is an example, but it is the same as in the application.

Me.Rst.AddNew 
Me.Rst("CODIGO").Value = 999 

After assigning the value in the CODE field of the recordset the error occurs:

  

-2147217887 - Multi-step operation generated errors. Check each status value.

I know this happens when you assign a value other than the type that is in recordset , but it is not the case, both are numeric.

Me.Rst.Close 
cnn.Close 
End Sub
    
asked by anonymous 19.09.2018 / 22:29

1 answer

0

To be able to add new records, the recordset can not be opened with adOpenStatic

Try replacing adOpenKeyset

Rst.Open sSql, cnn, adOpenKeyset, adLockBatchOptimistic, adCmdText 
    
02.10.2018 / 13:01