Aiuto ...sono disperato...Devo recuperare l'ultimo id inserito. Come faccio?
Faccio presente che :
ne ho provate mille, ma mi da sempre zero.
ecco il codice che ho sperimentato fin ora
Prendiamo per buona la mia variabile di connessione (funzionante e testata)
Codice PHP:' execute the insert
Set MM_editCmd = Server.CreateObject("ADODB.Command")
MM_editCmd.ActiveConnection = MM_editConnection
MM_editCmd.CommandText = "INSERT INTO ordinilibri (col1,col2)
VALUES ("value1"," value2") "
MM_editCmd.Execute
Set lastid = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT @@IDENTITY as last_id FROM ordinilibri "
lastid.ActiveConnection = MM_booga_STRING
lastid.Source = strSQL
lastid.CursorType = 1
lastid.CursorLocation = 2
lastid.LockType = 1
lastid.Open()
Response.Write(lastid("last_id"))
Purtroppo
Response.Write(lastid("last_id")) da sempre ZERO .....aiutooooooo

Rispondi quotando