By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,466 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,466 IT Pros & Developers. It's quick & easy.

ASP Javascript (Dreamweaver) insert and retreive Primary Key

P: 2
ASP Javascript (Dreamweaver) insert and retreive Primary Key

Been pulling my hair out all week.
I am working on a registration database, and need to get the last primary key allocated to a insert within the MySQL database. I am trying to use the LAST_INSERT_ID() function to return the value to a session variable.

if (!MM_abortEdit)
// execute the insert
var Data, mWedding_ID;
Session("iWedding_ID") = -4;
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.CommandText = "SELECT * FROM " + MM_editTable + ";";
MM_editCmd.CommandText = "SELECT LAST_INSERT_ID()";

if (MM_editRedirectUrl)
MM_editQuery = MM_editRedirectUrl + "?Wedding_ID=" + Session("iWedding_ID") + "XX";
// Response.Redirect(MM_editRedirectUrl + "?Wedding_ID=" + iWedding_ID);

With the Unique key, I need to put in into a URL string for the next page. For some reason the execute does not seem to return the value of the LAST_INSERT_ID() function. When I carry this out on the actual Database the right value is returned, but never when I try using the above script...

Does anyone know if .execute actually returns the value returned from the Last_Insert_ID();
Nov 23 '06 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,892
Are you trying to select the max ID?
Nov 24 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.