|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I am trying to capture the row ID of a new entry into my table. I have read about mysql_insert_id() in many places, but it's all PHP
examples. I thought I could just do recno = mysql_insert_id() and that would be it. But I ended up getting an error of data-type mismatch. So either I just need to declare my variable recno a different way. Or I am way off base... Any and all help is appreciated. Thank you mj |
|
#2
|
||||
|
||||
|
This is actually an ASP question, because you are using ADO to interface with the DB. Anyway, here's a great article that explains how to get the last inserted ID. If you need an extra hand, repost here, cos it can be a bit confusing first time around.
|
|
#3
|
|||
|
|||
|
The article is great, but it talks about SQL Server. Still, I believe that all you should do to get it to work with mySQL is to use the LAST_INSERT_ID() function.
Dim db,rcs,new_identity 'Create a database connection Set db = Server.CreateObject("adodb.connection") db.Open "DSN=MyDSN" 'Execute the INSERT statement and the SELECT LAST_INSERT_ID() Set rcs = db.execute("insert into tablename (fields,..) " & _ "values (values,...);" & _ "select LAST_INSERT_ID()").nextrecordset 'Retrieve the auto_increment value new_identity = rcs(0) |
|
#4
|
||||
|
||||
|
I just found this article - might be able to help you out: http://dbforums.com/t682190.html
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Insert with ASP and MySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|