ADO AddNew command with VB 6.0 and SQL 7.0 
Author Message
 ADO AddNew command with VB 6.0 and SQL 7.0

When I am trying to add a new record, then get the new SQL 7.0 generated ID field, I get the error shown below.

SQL = "Select * from contact WHERE id = 0"
DE.rsSQLContact.Open SQL, DE.SalesPro
DE.rsSQLContact.AddNew
DE.rsSQLContact.Update
DE.rsSQLContact.MoveLast
mContactId = DE.rsSQLContact!id

But I get an error:

"Run-time error 3021"
"Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."

Any Idea's ?

--
_________________________________
God Bless
Marco Napoli
Little Helpers of Our Loving Mother
Official Web Site for Nancy Fowler (visionary) in Conyers, GA USA
http://www.*-*-*.com/



Mon, 12 Aug 2002 03:00:00 GMT  
 ADO AddNew command with VB 6.0 and SQL 7.0

There are 2 things:
1. Identity fields are not seen until after you .Requery the recordset.
The drawback of requery is that the pointer is no longer on the last
added record so you have to reposition to the record you just added. So
if "id" that you use is an identity or autonumber field, you cannot see
it with your code
2. Pay attention to the query you generated:
SQL = "Select * from contact WHERE id = 0"
That means it only selects those records that have an id=0; probably
none of them meet the criteria, so don't expect to see any records.



Mon, 12 Aug 2002 03:00:00 GMT  
 ADO AddNew command with VB 6.0 and SQL 7.0

Sorry, found the answer, the RecordSet was set to read only.


  When I am trying to add a new record, then get the new SQL 7.0 generated ID field, I get the error shown below.

  SQL = "Select * from contact WHERE id = 0"
  DE.rsSQLContact.Open SQL, DE.SalesPro
  DE.rsSQLContact.AddNew
  DE.rsSQLContact.Update
  DE.rsSQLContact.MoveLast
  mContactId = DE.rsSQLContact!id

  But I get an error:

  "Run-time error 3021"
  "Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record."

  Any Idea's ?

  --
  _________________________________
  God Bless
  Marco Napoli
  Little Helpers of Our Loving Mother
  Official Web Site for Nancy Fowler (visionary) in Conyers, GA USA
  http://www.ourlovingmother.org



Mon, 12 Aug 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. How to get a field value after and AddNew command SQL 7.0 and VB 6

2. SQL Server 7.0 , ADO & VB 6.0

3. VB 6.0 / ADO 2.0 / SQL 7.0 Beta 3 (UniqueIdentifier)

4. How to ADO AddNew command with VB 6 and SQL 7

5. ADO 2.0, SQL Server 7.0, ServerSide cursors, IDENTITY columns after rs.AddNew

6. ADO addnew VB 6.0

7. Prointing problem CR 7.0 VB 6.0 w/ ADO

8. VB 6.0, SQL Server 7.0 and Images

9. VB 6.0, MTS, and SQL 7.0 Book

10. Store and retrieve image on SQL server 7.0 using VB 6.0

11. SQL Server 7.0 with VB 6.0 Enterprise

12. Boolean (SQL Server 7.0 & VB 6.0)

 

 
Powered by phpBB® Forum Software