Solved

I need the SQL for select max+1 for my ASP page.

Posted on 2004-04-29
3
250 Views
Last Modified: 2008-02-26
I have a HTML form that's saving data into a MS Access database using ASP.  The users need to see the next ID number on the form before the id number is created in the database.  I know this is just a simple select statement, but I can't seem to figure it out.

Here's what I've got:

---------------------------------------------------------------------------------------------------
'Initialize the strSQL variable with an SQL statement to query the database
strSQL1 = "SELECT max(its_number)+1 FROM tasks"

rsTask1.Open strSQL1, adoCon1

Response.Write strSQL1
---------------------------------------------------------------------------------------------------

I also need to do a response.write, and get that value printed out to the screen.  As of right now, my response.write just prints the sql.

Any help is greatly appreiciated!!
0
Comment
Question by:scross1276
  • 2
3 Comments
 
LVL 33

Accepted Solution

by:
Big Monty earned 20 total points
ID: 10952412
just add 1 in asp to the field:

'Initialize the strSQL variable with an SQL statement to query the database
strSQL1 = "SELECT max(its_number) FROM tasks"

rsTask1.Open strSQL1, adoCon1

Response.Write CInt(rsTask1(0)) + 1
0
 

Author Comment

by:scross1276
ID: 10952423
Sweet, it worked perfectly, thanks!!
0
 
LVL 33

Expert Comment

by:Big Monty
ID: 10952456
cheers!

B.D.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question