Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Determining if Request.Form is empty 1 46
Classic ASP - SQL Server connection problem 5 61
SQL Server Web Traffic Limitations 4 54
Choose the older file FSO 6 43
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

863 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

22 Experts available now in Live!

Get 1:1 Help Now