ADO + Access97: please help with AddNew-Method 
Author Message
 ADO + Access97: please help with AddNew-Method

hi,

Im using VB 6, ADO and Access97. In the VB-Frontend a form is
supported by a data aware class and i can read data, navigate, edit
and delete records. But Ive got difficulties in adding new records.

To add a new record, all controls are set to unbound mode in advance.
To save the record, a routine sends the data to a add-new-function in
the data class. If there is no record in the table, the first record I
insert in the form will be written to the database at once. All
following new records are only written to the buffer of the
ado-recordset of the data aware class. They are displayed in the form
so i can navigate forwards and backwards, but they are not saved to
disk. If I close the form or the application the 2nd and following
records are lost.

Ive tried all combinations of update-, updatebatch- and
requery-method with no luck.
Also I tried the AddNew-method with the fields- and values-argument.

Extracts from code:

Connection:
    Set DBSys = New ADODB.Connection
    DBSys.Provider = "Microsoft.Jet.OLEDB.3.51"
    DBSys.CursorLocation = adUseClient
    DBSys.Open "C:\.....mdb"

`Declare recordset in data aware class:
Private WithEvents RS_Main As ADODB.Recordset

Private Sub Class_Initialize()
Set RS_Main = New ADODB.Recordset
    sSQL = "SELECT * FROM std_Clients_S04"
    RS_Main.Open Source:=sSQL, ActiveConnection:=DBMain,
CursorType:=adOpenDynamic, LockType:=adLockOptimistic
...

Add new record:
Public Sub AddNew(ByVal sFieldArray)

    Dim iCnt1 As Integer

    RS_Main.AddNew
    For iCnt1 = LBound(sFieldArray, 2) To UBound(sFieldArray, 2)
        If sFieldArray(0, iCnt1) <> "" And sFieldArray(1, iCnt1) <> ""
Then
            RS_Main(sFieldArray(0, iCnt1)) = sFieldArray(1, iCnt1)
        End If
    Next iCnt1
    RS_Main.Update
    RS_Main.UpdateBatch

End Sub

Is there something missing?
 Any hints will be greatly appreciated

oliver




Sat, 28 Apr 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Help Please... AddNew Method error

2. .addnew method ADO does not work pls help

3. Cannot get autonumber after AddNew/Update with ADO (Visual Basic,Access97)

4. ADO Addnew PLEASE HELP !!!

5. PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP, PLEASE HELP,

6. Problem with ADO Recordset AddNew method

7. AddNew and Update ADO methods

8. ADO AddNew method

9. Oracle, ADO question (addnew method from VB)

10. using ado addnew method w/ asp

11. error msg 3251 on AddNew method for ADO/Brand New Jet database

12. ADDNEW-Method on ADO with SQL-Server [Newbie]

 

 
Powered by phpBB® Forum Software