473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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.Execute();
MM_editCmd.CommandText = "SELECT * FROM " + MM_editTable + ";";
MM_editCmd.Execute();
MM_editCmd.CommandText = "SELECT LAST_INSERT_ID()";
Session("iWedding_ID")=MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();

if (MM_editRedirectUrl)
{
MM_editQuery = MM_editRedirectUrl + "?Wedding_ID=" + Session("iWedding_ID") + "XX";
Response.Write(MM_editQuery);
// 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
1 2526
ronverdonk
4,258 Expert 4TB
LAST_INSERT_ID is only returned right after an INSERT, not after the SELECT

Ronald :cool:
Nov 23 '06 #2

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

Similar topics

4
by: davidshook | last post by:
I am a begginer with not too much time on my hand. I do some html pages with Dreamweaver and with some minor Flash actionscript and I have a minor ability (with the help of lots of tutorials) to do...
2
by: bbxrider | last post by:
i'm new to javascript but have programmed lots in vb, cobol, basic, etc jscript seems much more object oriented to me, much more direct manipulation of properties at least, than vb, don't know...
3
by: Bruce W.1 | last post by:
Can anyone recommend a Javascript debugger? I see where debuggers are made by Netscape, Microsoft and Macromedia (built-in to Dreamweaver). I'm new to javascript so any comments are appreciated....
1
by: John | last post by:
Hello, I'm working with Dreamweaver MX and we started to develop our website with Javascript too. However, unlike "Eclipse" for Java developement I don't have the support for Javascript code...
14
by: serge | last post by:
I have a scenario where two tables are in a One-to-Many relationship and I need to move the data from the Many table to the One table so that it becomes a One-to-One relationship. I need to...
5
by: Florence HENRY | last post by:
Hello, well, almost everything is in the subject ! I have to fill 2 tables (more complicated than in the example !): CREATE TABLE A ( id serial primary key, foo text);
1
by: Satish.Talyan | last post by:
hi, i want to create a dynamic tree hierarchy in javascript.there are two parts in tree, group & user.when we click on group then users come under that's tree category will be opened.problem is...
1
by: davemcdonald | last post by:
ASP Javascript (Dreamweaver) insert and retreive Primary Key -------------------------------------------------------------------------------- Been pulling my hair out all week. I am working on...
0
ak1dnar
by: ak1dnar | last post by:
There is a Error getting while i am entering records using this jsp file. <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %> <%@ include...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.