473,503 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP Javascript (Dreamweaver) insert and retreive Primary Key

2 New Member
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 1650
AricC
1,892 Recognized Expert Top Contributor
Are you trying to select the max ID?
Nov 24 '06 #2

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

Similar topics

4
3312
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...
3
4999
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
3343
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
4269
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
1728
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
4800
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
2528
by: davemcdonald | last post by:
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...
0
2135
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
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7357
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
7468
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5598
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,...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3171
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
402
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.