|
-
Aug 6th, 2000, 05:41 PM
#1
Thread Starter
Hyperactive Member
Here is my code. I want LastRecord to represent the # of records in my database that meet the search criteria. Please help me finish this code.
Code:
<%
Dim SearchCriteria
Dim cnn
Dim rst
Dim LastRecord
Dim counter
SearchCriteria = Request.Form("Criteria")
Set cnn = Server.CreateObject("ADODB.Connection")
Set rst = Server.CreateObject("ADODB.Recordset")
cnn.Open "DSN=test"
rst.Open "Select * FROM test where name = " & SearchCriteria, cnn
LastRecord = ????????
for counter = 0 to LastRecord
Response.write (rst("Telephone(Counter)"))
Next
rst.Close
cnn.Close
%>
If you think education is expensive, try ignorance.
-
Aug 7th, 2000, 03:50 AM
#2
Monday Morning Lunatic
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 7th, 2000, 04:00 AM
#3
The way you've opened up your recordset, RecordCount will return -1.
You need to open up your recordset like:
Code:
rst.Open "Select * FROM test where name = " & SearchCriteria, cnn, adOpenDynamic
You'll need to include the "adovbs.inc" file for VBScript to know what the hell "adOpenDynamic" means. If you haven't got this file then it's equal to 2.
-
Aug 7th, 2000, 04:05 AM
#4
While I'm at it, you should really kill off your connection and recordset objects when you've finished too. (More server memory friendly.) 
Stick this at the bottom of your script (after you've closed them):
Code:
Set cnn = Nothing
Set rst = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|