Classic ASP DatabasesDiscuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
This is in "old ASP" format, I don't know ASPX yet, so if you are using that, someone else will have to answer...
<% Response.Buffer = True %>
'This one will add a new row, obtain the new row ID, and pass it to the example2.asp
'Table contains three elements: ID, SomeInfo, MoreInfo
'ID is an autoincrement type
Set rsMessage = CreateObject("ADODB.Recordset")
rsMessage.Open "Message", "Messages", adOpenKeySet, adLockPessimistic, adCmdTable
rsMessage("SomeInfo") = InfoA
rsMessage("MoreInfo") = InfoB
'rsMessage.Update will return value of new row in rsMessage.ID
NewRowID = rsMessage("ID")
'Store the row ID in the session object. You could just pass this in QueryString, but
'not good security - could be exploited since it is passed to the client.
Session("NewRowID") = NewRowID
'Retrieve value from Session object (Not neccessarily needed, but makes for cleaner code)
RowID = Session("NewRowID")
'Display passed Row ID
Response.Write("New Row ID = " & RowID & "<br>")
'You now have the Row ID in RowID and can do whatever you want with it...
i am building registration over the web. but the survey is too long i can't put it in one age.
so what i do is to insert the data from one page, and other pages just update the row. so too keep the same primary key, i need to pass the primary key to next page.
i do not know how to get the primary key after inserting the data. and then i need some way to pass it to the next page.
You submit the form.. The form does it's work.. After the form has finished it's work there are a few options (There are more than 3.. I am just giving you 3 of them)
1. Set the identity to a Cookie on the users macine
2. Put the identity in the session
3. On the redirect to the second form after the first is done- append the ID to the URL and then retrieve it from the URL on the second page.
Hey, .NET isn't my thing, but surely you need some object which enables you to get at the row returned by the SQL statement - e.g. a Recordset object in classic ADO. I'm sure someone else can tell you what the .NET equivalent is, or maybe you could look it up in MSDN...