Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Retrieving one record out of 1000 from tabel

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-04-26 : 10:58:19
Malte writes "Please help
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
' database

Dim connStr
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("simply_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


Thankyou for your Help.
regards Malte"

dsdeming

479 Posts

Posted - 2002-04-26 : 11:21:31
Assuming the seat numbers come up in order from 1 to 1000 and you do delete each one after it is assigned:

SELECT MAX( [02seatno_mad1000].i1_seatno )
FROM 02seatno_mad1000


Go to Top of Page
   

- Advertisement -