AutoNumber field with ADO/VB6/DataEnvironment

AutoNumber field with ADO/VB6/DataEnvironment

Post by ASP Ki » Sat, 30 Jan 1999 04:00:00

Hi everyone!
I'm using VB6, ADO and the DataEnvironment to browse and add records to an
Access 97 database.
I want to retrieve the value of the autonumber field of a newly added
record. I CAN get it if I DON'T use the DataEnvironment to connect to my
database. After using the update methode on my RecordSet the current record
is the new one, I can read each field except the autonumber, which is always
null. Is-it a bug of the DataEnvironment?



1. Cannot Get Autonumber field - using DataEnvironment?

I'm having trouble getting the primary key of a record:

I have a Dataenviroment with a connection to a Access database, the database
has three tables.

In the code I can adding a new record and then updating the record. I want
to get the record ID number of the record I just added.

In an ASP application I have I get the record ID after I update the record.
When I try this in VB it doesnt work.

Here is the code:

        ' Profiles is the name of the table

        DE.rsProfiles.Fields(1).Value = txtCategory.Text
        DE.rsProfiles.Fields(2).Value = txtCountry.Text
        DE.rsProfiles.Fields(3).Value = txtDate.Text
        DE.rsProfiles.Fields(4).Value = txtTitle.Text
        DE.rsProfiles.Fields(5).Value = txtProfile.Text
        DE.rsProfiles.Fields(6).Value = txtLocation.Text
        DE.rsProfiles.Fields(7).Value = txtH1.Text
        DE.rsProfiles.Fields(8).Value = txtP1.Text
        DE.rsProfiles.Fields(9).Value = txtBody.Text

        ' I'm saving details of this record here
        ThisRec = DE.rsProfiles.Fields(5).Value
        ThisDate = DE.rsProfiles.Fields(3).Value
        ThisTitle = DE.rsProfiles.Fields(4).Value

        ' I want to get the record's autonumber field:
        ' I have tried these, but not together....
        ThisID = DE.rsProfiles.Fields(0).Value
        ThisID = DE.rsProfiles.Fields(0)


I'm always getting a null value to ThisID??? What am I doing wrong??

2. which is better way between cascade delete and a trigger in SQL 2k ?

3. Access and VB6: fields of type autonumber

4. THREADLIB setting in UNIX

5. ADO Bug VB6 Linked to Access Using Autonumber

6. DB compiler developer for Bay Area startup

7. Adding Autonumber field to access database in VB6 ???

8. It's Been Awhile - Backup Strategies for IDS 7.x

9. ADO 2.5/JET 4 AutoNumber Field Bug?

10. ADO and Autonumber fields

11. Creating Autonumber field using ADO

12. ADO and AutoNumber fields

13. Accessing autonumber fields with ADO