michael
|
Posted: 01/31/2002, 3:00 PM |
|
In my after insert event, I enter
last_id=mysql_insert_id()
cn.execute "insert into logistics (vrma_id, product_id, quantity, vendor_id) "& _
"values("& _
tosql(last_id, "Number") & "," & _
tosql(fldproduct_id, "Number") & "," & _
tosql(fldquantity, "Number") & "," & _
tosql(fldvendor_id, "Text") & _
")"
I got,
Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'mysql_insert_id'
Does anyone help on this, I try to transfer a table primary key to another table's field
Thanks
|
|
|
CodeCharge Support
|
Posted: 01/31/2002, 4:46 PM |
|
mysql_insert_id()is a PHP function which does not have a ASP equivalent. However, you can use the Last_Insert_ID mySQL function to achieve the same effect as explained below:
http://www.mysql.com/doc/O/D/ODBC_and_last_insert_id.html
|
|
|
mike
|
Posted: 01/31/2002, 10:03 PM |
|
I still got the same error message. Can you explain more? Sorry for the troublesome.
|
|
|
Nicole
|
Posted: 02/01/2002, 1:19 AM |
|
Michael,
you cannot use mysql functions directly in asp code the same way as asp functions. Mysql functions could be used inside queries only. Try to use the following code to get the value of last inserted primary key:
last_id = dLookUp("any_table_name", "LAST_INSERT_ID()", "1=1")
|
|
|
michael
|
Posted: 02/04/2002, 1:17 AM |
|
Nicole,
Thanks for the tips, but it still doesn't work. I have revised by your hints as the follow, and it works
last_id = dLookUp("vrma", "vrma_id", "vrma_id=last_insert_id()")
cn.execute "insert into logistics (vrma_id, product_id, quantity, vendor_id) values ("&tosql(last_id, "Number")&","&tosql(fldproduct_id, "Number")&","&tosql(fldquantity, "Number")&","&tosql(fldvendor_id, "Text")&")"
|
|
|
|