Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 19th, 2003, 03:43 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What about the code around this statement? Maybe the error occurs on another line:

Do While Not oRSmt.EOF
    Response.Write(oRSmt("FirstName") & "<br>")
    oRSmt.MoveNext()
Loop

should just work, but maybe you added something that you didn't show here.

Imar

---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 19th, 2003, 07:43 AM
CW CW is offline
Authorized User
 
Join Date: Sep 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is the complete code of detail.asp

<html>
<head>
<title>detail</title>
</head>
<body>
<BR>
<%
UserID = Request.QueryString("ID")
dim oRSmt
set oRSmt=server.createobject("ADODB.recordset")
sqlText="Select * FROM Student"
sqlText=sqlText & "WHERE ID="& UserID & ""
oRSmt.Open sqlText, "DSN=Arday"

Do While Not oRSmt.EOF
Response.Write(oRSmt("FirstName") & "<br>")
oRSmt.MoveNext()
Loop

oRSmt.Close
Set oRSmt = Nothing
%>
</body>
</html>

this is the same error.

Error Type:
Microsoft VBScript compilation (0x800A0408)
Invalid character
/Thesis/test3.asp, line 16
    Response.Write(oRSmt("FirstName")&"<br>")




thanks again
what you think.




 
Old October 19th, 2003, 08:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Not sure whether this is a copy / paste error, but take a look at this:

sqlText="Select * FROM Student"
sqlText=sqlText & "WHERE ID="& UserID & ""


The SQL statement will end up like this:

Select * FROM StudentWHERE ID=12

There should be a space between the Student and WHERE clause.

Also, when you are querying for just one record (I assume the UserID is unique), there is no need for a loop:


If Not oRSmt.EOF Then
    Response.Write(oRSmt("FirstName") & "<br>")
End If

This will write out just one record, because your WHERE clause will just return one record.

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old October 21st, 2003, 03:58 AM
CW CW is offline
Authorized User
 
Join Date: Sep 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot. It is working.

Thanks






Similar Threads
Thread Thread Starter Forum Replies Last Post
ADD DB RECORD/ RETURN ID Huascar82 Classic ASP Databases 1 October 1st, 2007 11:55 PM
Update DB by passing ID number jonsey Classic ASP Professional 1 April 11th, 2007 07:05 PM
Attempting to Insert Value into DB Query Snuffles ASP.NET 2.0 Basics 2 April 2nd, 2007 08:17 AM
Passing ID query rsm42 ASP.NET 1.0 and 1.1 Basics 2 January 7th, 2007 10:45 AM
why not index.asp?id=1 can be www.myweb.com/?id=1 BurhanKhan Classic ASP Professional 11 September 6th, 2004 02:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.