Solved

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

Posted on 2004-04-29
3
244 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 32

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 32

Expert Comment

by:Big Monty
ID: 10952456
cheers!

B.D.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Grab data from remote page 10 57
SQL Server Web Traffic Limitations 4 42
Group by correlation 4 43
XML Parsing Classic ASP 5 42
I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now