Adding records to Oracle using VB6 class
127934Jan 24 2005 — edited Jan 25 2005I have a problem using VB6 and a Class Object generated by the Data Form Wizard. I've created two sample programs, both using ODBC DSN connections and a form/class generated using the Single Record form layout. One program's ODBC connection points to an Access database and the other program uses and ODBC connection to an Oracle database. Both databases have a table I've called Vendor_Code. The Access table has a primary key with Autonumber feature on the Vendor_ID and the Oracle table is defined as Not Null and Unique for its Vendor_ID field with an Oracle Sequence created to supply a next sequence value.
My sample program using the Access database works fine when adding a new record but the other program connecting to Oracle fails trying to add a new record with the message:
Error '-2147467259(80004005)': "Method 'AddNew' of object '_Recordset' failed.
I suspect the problem is when creating a new Oracle record, the Vendor_ID field is not being populated with the next sequence number. VB6 seems to hide the details of actually creating a new record and I don't know how to get the next sequence value from Oracle then place that value into the recordset before VB tries to insert the new record. The version of Oracle the company is using is Oracle 9 with Oracle 8.1.7 client.
How do you get a VB6 class object to create a new record in Oracle which includes an Oracle generated sequence number since a SQL Insert statement is not being issued? How do I get the dataBinding with VB6 classes to interact with Oracle databases?
Thanks,
Vince