INSERT using ADO with Jet database 
Author Message
 INSERT using ADO with Jet database

I am using ADO with VC6.0.  My tables have auto-number fields.  What is the
best way to insert a record and get back that auto-number value?

I've gotten it to work by SELECTing the table, doing a rs->AddNew,
rs-Update, rs->MoveLast.  However, this seems completly inefficient
(selecting the table) and doesn't seem correct (MoveLast).

I've also tried doing an INSERT INTO.  However, this closes the recordset
after the insert (I get back 0x800A0E78 - adErrObjectClosed for any
operation).

What I would like is an easy way to add a record and be bound to it.

Thanks in advance,
Andy



Fri, 08 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
Hi Andy,

According to the documentation, when using ADO, after calling the Update method
of the Recordset interface the current record remains current so you should be
able to just reference the field in question.

Don't take my word for it as I am still pretty new to ADO.

HTH
--
=================
Frank Hickman
NobleSoft, Inc.


=================



Fri, 08 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database

Quote:
>I am using ADO with VC6.0.  My tables have auto-number fields.  What is the
>best way to insert a record and get back that auto-number value?

>I've gotten it to work by SELECTing the table, doing a rs->AddNew,
>rs-Update, rs->MoveLast.  However, this seems completly inefficient
>(selecting the table) and doesn't seem correct (MoveLast).

Dont move to last record, use something like
SetBookmarkPostition(myRecordset.GetLastModifiedBookmark());

That worked in DAO.




Sat, 09 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database

Quote:

>Hi Andy,

>According to the documentation, when using ADO, after calling the Update
method
>of the Recordset interface the current record remains current so you should
be
>able to just reference the field in question.

Yes, that is what the documentation says.  However, it doesn't work.  If I
remember correctly, the new record is current, but you cannot see the
correct value of the AutoIncrement field.
Quote:

>Don't take my word for it as I am still pretty new to ADO.

>HTH
>--
>=================
>Frank Hickman
>NobleSoft, Inc.


>=================



Sat, 09 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
I can definitely confirm that this does not work in ADO 2.0 .  It used to in
ADO 1.5.
S
Quote:




Quote:
>>Hi Andy,

>>According to the documentation, when using ADO, after calling the Update
>method
>>of the Recordset interface the current record remains current so you
should
>be
>>able to just reference the field in question.

>Yes, that is what the documentation says.  However, it doesn't work.  If I
>remember correctly, the new record is current, but you cannot see the
>correct value of the AutoIncrement field.

>>Don't take my word for it as I am still pretty new to ADO.

>>HTH
>>--
>>=================
>>Frank Hickman
>>NobleSoft, Inc.


>>=================



Sat, 09 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
How did you work around the bug?


Sat, 09 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
Unfortuantly, ADO has no equivelent to GetLastModifiedBookmark.

Vincent Minden


Quote:
>>I am using ADO with VC6.0.  My tables have auto-number fields.  What is
the
>>best way to insert a record and get back that auto-number value?

>>I've gotten it to work by SELECTing the table, doing a rs->AddNew,
>>rs-Update, rs->MoveLast.  However, this seems completly inefficient
>>(selecting the table) and doesn't seem correct (MoveLast).

>Dont move to last record, use something like
>SetBookmarkPostition(myRecordset.GetLastModifiedBookmark());

>That worked in DAO.





Sun, 10 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
To be clear using AddNew and Update then reading the Field value of an
auto-inc field in a Jet database table definitely does work with both ADO
2.0 and ADO 1.5.

I don't know about calling the SQL INSERT statement directly.

Regards
Jeremy


Quote:
>I can definitely confirm that this does not work in ADO 2.0 .  It used to
in
>ADO 1.5.
>S



>>>Hi Andy,

>>>According to the documentation, when using ADO, after calling the Update
>>method
>>>of the Recordset interface the current record remains current so you
>should
>>be
>>>able to just reference the field in question.

>>Yes, that is what the documentation says.  However, it doesn't work.  If I
>>remember correctly, the new record is current, but you cannot see the
>>correct value of the AutoIncrement field.

>>>Don't take my word for it as I am still pretty new to ADO.

>>>HTH
>>>--
>>>=================
>>>Frank Hickman
>>>NobleSoft, Inc.


>>>=================



Thu, 14 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
Check out:

INFO: Identity (AutoIncrement) Columns in ADO or RDS          [adobj]
ID: Q195910    CREATED: 17-NOV-1998   MODIFIED: 17-NOV-1998

According to "ADO 2.0 Programmer's Reference" (Sussman and Homer) p. 210,
the Jet
OLE DB Provider does this properly, so if you are currently using the
Access ODBC Driver from ADO, switching to the Jet OLE DB Provider
may solve your problem.

Matt

Quote:

>I am using ADO with VC6.0.  My tables have auto-number fields.  What is the
>best way to insert a record and get back that auto-number value?

>I've gotten it to work by SELECTing the table, doing a rs->AddNew,
>rs-Update, rs->MoveLast.  However, this seems completly inefficient
>(selecting the table) and doesn't seem correct (MoveLast).

>I've also tried doing an INSERT INTO.  However, this closes the recordset
>after the insert (I get back 0x800A0E78 - adErrObjectClosed for any
>operation).

>What I would like is an easy way to add a record and be bound to it.

>Thanks in advance,
>Andy




Thu, 14 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
Unfortunately, it does not if using VC++ extentions. BindToRecordset fails.
--
Eugene Novikov / ANTEC


Quote:
>To be clear using AddNew and Update then reading the Field value of an
>auto-inc field in a Jet database table definitely does work with both ADO
>2.0 and ADO 1.5.

>I don't know about calling the SQL INSERT statement directly.

>Regards
>Jeremy



>>I can definitely confirm that this does not work in ADO 2.0 .  It used to
>in
>>ADO 1.5.
>>S



>>>>Hi Andy,

>>>>According to the documentation, when using ADO, after calling the Update
>>>method
>>>>of the Recordset interface the current record remains current so you
>>should
>>>be
>>>>able to just reference the field in question.

>>>Yes, that is what the documentation says.  However, it doesn't work.  If
I
>>>remember correctly, the new record is current, but you cannot see the
>>>correct value of the AutoIncrement field.

>>>>Don't take my word for it as I am still pretty new to ADO.

>>>>HTH
>>>>--
>>>>=================
>>>>Frank Hickman
>>>>NobleSoft, Inc.


>>>>=================



Fri, 15 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
Unfortunately, it does not if using VC++ extentions. BindToRecordset fails.
--
Eugene Novikov / ANTEC


Quote:
>To be clear using AddNew and Update then reading the Field value of an
>auto-inc field in a Jet database table definitely does work with both ADO
>2.0 and ADO 1.5.

>I don't know about calling the SQL INSERT statement directly.

>Regards
>Jeremy



>>I can definitely confirm that this does not work in ADO 2.0 .  It used to
>in
>>ADO 1.5.
>>S



>>>>Hi Andy,

>>>>According to the documentation, when using ADO, after calling the Update
>>>method
>>>>of the Recordset interface the current record remains current so you
>>should
>>>be
>>>>able to just reference the field in question.

>>>Yes, that is what the documentation says.  However, it doesn't work.  If
I
>>>remember correctly, the new record is current, but you cannot see the
>>>correct value of the AutoIncrement field.

>>>>Don't take my word for it as I am still pretty new to ADO.

>>>>HTH
>>>>--
>>>>=================
>>>>Frank Hickman
>>>>NobleSoft, Inc.


>>>>=================



Fri, 15 Jun 2001 03:00:00 GMT  
 INSERT using ADO with Jet database
This could be because you cannot set the value of an autoinc field. ADO gets
very stroppy if you try to do this.

I work directly with ADO using the VC #import templates. All my base code
was developed before ADO 2.0 and the VC++ extensions were around - I haven't
even looked at them yet, and probably won't. Try coding down a level. You
*can* get at this information.

Jeremy

Quote:

>Unfortunately, it does not if using VC++ extentions. BindToRecordset fails.
>--
>Eugene Novikov / ANTEC



>>To be clear using AddNew and Update then reading the Field value of an
>>auto-inc field in a Jet database table definitely does work with both ADO
>>2.0 and ADO 1.5.

>>I don't know about calling the SQL INSERT statement directly.

>>Regards
>>Jeremy



>>>I can definitely confirm that this does not work in ADO 2.0 .  It used to
>>in
>>>ADO 1.5.
>>>S



>>>>>Hi Andy,

>>>>>According to the documentation, when using ADO, after calling the
Update
>>>>method
>>>>>of the Recordset interface the current record remains current so you
>>>should
>>>>be
>>>>>able to just reference the field in question.

>>>>Yes, that is what the documentation says.  However, it doesn't work.  If
>I
>>>>remember correctly, the new record is current, but you cannot see the
>>>>correct value of the AutoIncrement field.

>>>>>Don't take my word for it as I am still pretty new to ADO.

>>>>>HTH
>>>>>--
>>>>>=================
>>>>>Frank Hickman
>>>>>NobleSoft, Inc.


>>>>>=================



Fri, 15 Jun 2001 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. INSERT using Jet database

2. ADO/ATL/Jet 4.0 Provider problems with INSERT-sql

3. How to connect to a Jet database, insert a row, and disconnect via MFC

4. Jet Database Replication (JRO + ADO)

5. Read Jet-database properties with ADO

6. Inserting many rows in a database with a single ADO function

7. Problem using ODBC and Jet Database

8. Distributing Applications using Access (Jet) Database

9. Using Jet 4.0 Unicode databases with DAO

10. How can I create a new database using OLEDB provider for Microsof t Jet Engine 4.0

11. Not able to insert Milliseconds using ADO

12. Insert blob data into oracle using ADO

 

 
Powered by phpBB® Forum Software