Wrox Programmer Forums
|
Classic ASP Databases Discuss 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 30th, 2010, 11:04 AM
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default If last record then redirect

Hello,

I am new to asp and programming. I am trying to complete a form I have successfully don the input and edit. I have been asked that on the edit page if the user edits the last question then the user gets re-directed to another page.
Could I do something like
Code:
If objRS.AbsolutePosition = last then response.redirect(mypage.asp)
I would really appreciate any kind of advice or help

Thank you!!
 
Old June 30th, 2010, 04:40 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

?? Do you mean *AFTER* he edits the last record? That is, after you have saved the edit results back to the DB?

Or do you mean that you ignore his edits to that record and just run off to the other page?

It's a little hard to give you a general answer without knowing more about how you are doing things. Do you present the user with MANY records to edit, all on the same web page?

Or does the user have to edit all the records one at a time, from start to finish, one per web page?
 
Old June 30th, 2010, 05:04 PM
Registered User
 
Join Date: Jun 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Old Pedant,
It would be after the user edits the last record, it does not matter if he/she has filled out all the other questions. if the last record gets updated then redirect to signature page
 
Old June 30th, 2010, 06:08 PM
Friend of Wrox
 
Join Date: Jun 2008
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Okay, but what is the definition of "last record". Databases do *NOT* have any inherent concept of record ordering. The only way you define a "first record" or "nth record" or "last record" is to use an ORDER BY in your SQL query.

So I'm going to make some assumptions, as you didn't fill me in with more details:

-- I assume that your query that gets the records is doing "ORDER BY xyzID"
-- I assume that in your <form> you have stored that xyzID into some field
. . (presumably via <input type="hidden" name="id" value="<%=RS("xysID"%>" /> or equivalent)

So it's pretty easy:

On the page that the <form> submits to you will get all the form fields:
Code:
<%
id = Request("id")
name = Request("name")
framitz = Request("framitz")
 
' update the record with the given id
SQL = "UPDATE table SET name = '" & name & "', framitz='" & framitz & "' WHERE xysID = " & id
conn.Execute SQL
 
Set RS = conn.Execute( "SELECT MAX(xysID) FROM table" )
maxid = RS(0)
RS.Close
 
If maxid = id Then Response.Redirect "youAreDone.asp"
...
%>
You see? I am using MAX(xysID) because that matches the "ORDER BY xysID" that was used to populate the <form>.

If you showed me more details of your situation, there might be a slightly different answer, but it would be close to the same.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Last Record and Add new keyed record causualuser Access VBA 3 February 9th, 2009 08:24 AM
clicking through from record to record on form mat41 Access 3 January 9th, 2009 08:26 AM
how to add new record as first record in dataset [email protected] ASP.NET 1.0 and 1.1 Professional 4 April 21st, 2006 05:23 AM
Record locking - user needs the next queued record cbtoolkit SQL Server 2000 0 December 6th, 2004 08:29 AM
Sub record not associating with Main record Ron V Access 1 August 31st, 2004 09:21 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.