This works for me. You will have to translate the javascript to whatever you are using
...
SQL = "insert into myTable(field2, field3, field4) values("dat2", "dat3", "dat4")"
var dataConn = Server.CreateObject("ADODB.Connection");
dataConn.open(MM_soCalData_STRING);
var rs1 = dataConn.Execute(SQL); // Here my record is inserted
rs1 = null;
SQL = "select field1 from myTable where field1 = last_insert_id()"; //field1 is the
auto_increment field
var rs2 = dataConn.Execute(SQL)
if (rs2.Eof==false){
lastIDvar = rs2("field1");
rs2 = null;
}
Fred van Engen wrote:
> On Sun, Apr 29, 2001 at 03:38:07PM +0200, [EMAIL PROTECTED] wrote:
> > My insert query look like your
> > 'INSERT INTO ordinit(ID_ordine, Cod_Cliente) VALUES (NULL, 10);';
> > after the query I look into the table 'ordinit' and always looks fine: the value of
> > ID_ordine is really incremented.
> > But the following 'select LAST_INSERT_ID()' return zero :-((
>
> Weird. I've used them often (on ISAM tables) and it works just fine.
>
> Do you use the same connection for the 'LAST_INSERT_ID' query as for
> the INSERT query? The LAST_INSERT_ID is kept per connection and until
> another INSERT is done.
>
> Regards,
>
> Fred.
>
> > >What does your INSERT query look like? It should specify NULL
> > >for ID_ordine, e.g.:
> >
> > >INSERT INTO ordinit(ID_ordine, Cod_Cliente) VALUES (NULL, 10);
> >
> > >Any other value for ID_ordine will not assign an auto_increment
> > >value.
> >
> >
>
> --
> Fred van Engen XO Communications B.V.
> email: [EMAIL PROTECTED] Televisieweg 2
> tel: +31 36 5462400 1322 AC Almere
> fax: +31 36 5462424 The Netherlands
>
> ---------------------------------------------------------------------
> 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
---------------------------------------------------------------------
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