I am having trouble reading the ID Field (auto incremented primary key) back
after creating a new record in an update. The new record is created OK but
the ID is not available to me. I have found related advice in the archives
at http://lists.mysql.com/cgi-ez/ezmlm-cgi?1:mss:73847 and
http://lists.mysql.com/cgi-ez/ezmlm-cgi?1:mss:23959 but this has not helped
me. I understand that the table being updated needs to be indexed on the
field being read back but this approach doesn't seem to be working for some
reason.

I have included some code below: The function Add returns nothing. Any
ideas?

cheers

Murray

------

The asp code looks like this:

Function Add()
  Dim adoRec
  Set adoRec = Server.CreateObject("ADODB.Recordset")
  With adoRec
    .Open "Test", Connection, adOpenDynamic, adLockOptimistic, adCmdTable
    .AddNew
    .Fields("Name") = "Added"
    .Update
    Add = .Fields("TestID")
  End With
  adoRec.Close
  Set adoRec = Nothing
End Function

And the table has the correct definition for "TestID" I believe:

mysql> describe test;
+--------+------------------+------+-----+---------+----------------+
| Field  | Type             | Null | Key | Default | Extra          |
+--------+------------------+------+-----+---------+----------------+
| TestID | int(10) unsigned |      | PRI | NULL    | auto_increment |
| Name   | varchar(20)      |      |     |         |                |
+--------+------------------+------+-----+---------+----------------+

Platform:
- Win 2K
- My ODBC
- 3.23.38-nt




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to