I have the id field which is a primary key, identifer, and auto generated. but after insert statement, I can not get the id right away:
Set rs2 = conn.Execute("INSERT INTO Cart VALUES ('2/01/01','','" & strCONTROL & "' )"
Tempid=rs2("id"
would give me something like "operation is not allwed since the object is closed"
so, I have to use SELECT statment to get the last generated id:
Set rs3 = conn.Execute("SELECT * FROM Cart WHERE control= '" & strCONTROL & "' order by id desc"
rs3.MoveFirst
Response.Cookies("cart"
("ID"
= rs3("id"
is there a way that I can get the id right away after I did the INSERT statment or when I am doing a INSERT statment, so I do not have to do a SELECT statment again later on to get that id?
if there is no way that I can catch the id field right after INSERT, can some one give me some detail on how to use @@IDENTITY ?
in SQL, is make a new field called identityid, make it a uniqueidentifier,put (newid()) in default name enough for SQL part? it is not going to be a primary key though, the id is. then in ASP part, how do I get it right after INSERT statment?
Set rs2 = conn.Execute("INSERT INTO Cart VALUES ('2/01/01','','" & strCONTROL & "' )"
Tempstr = rs3("identityid"
am I able to get the unique identifier right away after insert? or I can't because the object is closed?
Set rs2 = conn.Execute("INSERT INTO Cart VALUES ('2/01/01','','" & strCONTROL & "' )"
Tempid=rs2("id"
would give me something like "operation is not allwed since the object is closed"
so, I have to use SELECT statment to get the last generated id:
Set rs3 = conn.Execute("SELECT * FROM Cart WHERE control= '" & strCONTROL & "' order by id desc"
rs3.MoveFirst
Response.Cookies("cart"
is there a way that I can get the id right away after I did the INSERT statment or when I am doing a INSERT statment, so I do not have to do a SELECT statment again later on to get that id?
if there is no way that I can catch the id field right after INSERT, can some one give me some detail on how to use @@IDENTITY ?
in SQL, is make a new field called identityid, make it a uniqueidentifier,put (newid()) in default name enough for SQL part? it is not going to be a primary key though, the id is. then in ASP part, how do I get it right after INSERT statment?
Set rs2 = conn.Execute("INSERT INTO Cart VALUES ('2/01/01','','" & strCONTROL & "' )"
Tempstr = rs3("identityid"
am I able to get the unique identifier right away after insert? or I can't because the object is closed?