Discussion Locked

Get one record out of 1000 from tabel

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a table with 1000 seatnumbers. Everytime the website is accessed a new seat should come up (starting with 1 up to 1000) . After the seat came up, it should be deleted from the table. I have used a stored procedure and I call it in ASP.
How should the SELECT statement look like in the stored proc.?
I have now this, which will show all 1000 seats at once:
Stored procedure:

SELECT [02seatno_mad1000].i1_seatno
FROM 02seatno_mad1000;

The ASP:

<%
' Connection String' Provide relative path to your StoredProc.mdb
' database
Dim reservat_date
Dim i1_seatno

reservat_date = Date()

' Connection String
' Provide relative path to your StoredProc.mdb
' databaseDim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("Netwings_db1.mdb")

' Connection Object
Dim con
Set con = Server.CreateObject("ADODB.Connection")

Dim rs
' connecting to database
con.Open connStr

' executing stored procedure
Set rs = con.Execute ("exec call_seat_mad 'i1_seatno'")
' showing all records
While Not rs.EOF
Response.Write rs(0) & ""
rs.MoveNext
Wend

' closing connection and freeing resources
con.Close

Set rs = Nothing

Set con = Nothing
%>

1 reply

by rwblaas

select top 1
from
order by desc

Alternatively you could just use
and identifier field to create the number.
Check out BOL for use of identifiers in SQL.

This discussion is closed to new replies.