| | |
|
Active Server Pages ASP control controls class classes module script Scripts applet CJWSoft ASPProtect ASPBanner ASPClassifieds
(Advanced)
(Components)
(Database)
(General)
(Vbscript)

|
|
Subject: |
Re: Inserting to related tables, on different pages |
From: |
Harlan |
Date: |
3/22/1999 8:52:12 AM |
IP: |
206.222.20.2 |
I guess my question is (after all this rambling)
1. does this seem like it will work?
-yep I do it all the time, almost exactly as you have described.
2. do i need to save the recordID in a session object, or will passing it as a hidden value from page to page be enough.
-either will work, but hidden fields is generally a better way to do it if you are sure they will
always be using a form to "post/get" the hidden fields onto the next page.
3. if I can grab the recordID value from my new record i just posted, can i also grab values such as username, and location?
-well of course you can both get the id and any
values you want. You will have to do it in a
select statement. There is no way to return a
value from an insert. But its really easy to
get that field, and only that field. Here is
how I do it.. (posted directly from a dll of mine I'm working on now)
sqlTests = "INSERT INTO tests " & _
"(name,typeid,classid) VALUES ('" & _
Trim(strClassName) & "'," & _
intTypeID & ",'" & _
Trim(strClassID) & "')"
'in order to insert into the class table, we have to know
'the classid.. so we have to select the one we just inserted
'back out of the db for its classid..
sqlClassID = "SELECT testid from tests where classid='" & strClassID & "'"
DBOpen 'open the database
DB.BeginTrans
DB.Execute (sqlTests) 'run the insert statement
'run our query
Set rsClassID = DB.Execute(sqlClassID)
'if we don't get back a classID then something is wrong
If rsClassID.EOF And rsClassID.BOF Then
DB.RollbackTrans 'if there is an error at this point, we
'need to rollback our transaction so we don't save 1/2 the test.
createClass = False
errMessage = "Error: " & errUnknown & " :cc0160"
Exit Function
Else 'if we do get back a classID everything is fine.
intTestID = rsClassID("TestID")
End If
note: this is only partial code, don't attempt to use it. Its also not asp, but the concept is the same.
|
Previous Message
|
|

|
|
|
|