LAST_INSERT_ID() with OLEDB and ASP returns 0

I am trying to retrieve the auto increment ID of a record inserted into a MySQL table.  I am using the MyOLEDB 3 driver with ADO in ASP (JScript).  The INSERT statement is successful but a subsequent call to execute SELECT LAST_INSERT_ID() always returns 0.  My code (simplified) is below:

var sSql="INSERT INTO Registration (RegistrationID, name, email) VALUES (NULL, 'Me', '')";
var iRegID=oConn.Execute(sSql).Fields(0).Value;

Who is Participating?
moduloConnect With a Mentor Commented:
PAQed with points refunded (500)

Community Support Moderator
UmeshMySQL Principle Technical Support EngineerCommented:
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

pattoiAuthor Commented:
I have alread looked at both of these articles today and neither of them addresses my problem.  The Experts Exchange item is about a problem that the ID returned is from a different table whereas I am getting 0.  I tried that solution anyway and still get 0.  I also tried the solution from the 4 Guys from Rolla article but I get an error trying to execute the 2 commands separated by a semi-colon.
Try to run your script with this query:
var sSql="INSERT INTO Registration (name, email) VALUES ('Me', '')";
pattoiAuthor Commented:
I have alread tried this also without any success
pattoiAuthor Commented:
I tried the same code using the MyODBC Driver instead and it works fine so obviously the problem is with MyOLEDB.  That's enough of a solution for me now.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.