Error inserting data into recordset with oraOLEDB

Asked

Viewed 125 times

0

Good afternoon, everyone.

I have a problem in various 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), but it only happens when I use the preview oraOLEDB. To the MSDAORA works normally. I set an example to do the tests, basically with the instructions that are in the application.
If anyone can help I’d appreciate it!

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 the 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’s the same as in the application.

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

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

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

I know this happens when you assign a different value to the type that is in recordset, but this is not the case, both are numerical.

Me.Rst.Close 
cnn.Close 
End Sub

1 answer

0

To add new records, the recordset cannot be opened with adOpenStatic

Try replacing with adOpenKeyset

Rst.Open sSql, cnn, adOpenKeyset, adLockBatchOptimistic, adCmdText 
  • I already used adOpenKeyset as a standard in the recordsets opening and according to Oracle documentation (https://docs.oracle.com/cd/E51173_01/win.122/e18594/using.htm#OLEDB003), for the Provider Oraoledb, the only supported types are adOpenStatic and adOpenForwardOnly. I actually identified the problem, but I don’t have the solution yet. The error occurs when there is a subquery in my SELECT.

  • For these more complex cases, I advise you to use another type of solution. cnn.execute "UPDATE Table set field=value from Table (...) Join (select field from Table 2) ... "

Browser other questions tagged

You are not signed in. Login or sign up in order to post.