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 23rd, 2003, 12:52 PM
Registered User
 
Join Date: Oct 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem using WHERE clause in opening Recordset

I pretty new to ASP and this problem it causing me a major headache.

Code Sample start
Set objRec = Server.CreateObject ("ADODB.Recordset")
'================
objRec.CursorLocation=adUseClient 'clientside
objRec.CursorType=adOpenStatic 'staticrecordset
objRec.PageSize=bsPageSize
'=====================
objRec.Open strSQL, strConnect, adOpenStatic, _
                adLockReadOnly, adCmdText
Code Sample End

Where strConnect is "DSN = A+ Comics"

I don't have a problem when i use:
strSQL is "SELECT * FROM tblBookInformation"

I get "Page Not found" problem when i use:
strSQL is "SELECT * FROM tblBookInformation WHERE book_title like '%One%' "
 
Old October 23rd, 2003, 01:08 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You have to create the connection first before you open the recordset:

'Create connection object and open it
Set objCnn = Server.CreateObject ("ADODB.Connection")
objCnn.Open strConnect

Set objRec = Server.CreateObject ("ADODB.Recordset")
'================
objRec.CursorLocation=adUseClient 'clientside
objRec.CursorType=adOpenStatic 'staticrecordset
objRec.PageSize=bsPageSize
'========** changes below: strconnect -> objCnn **
objRec.Open strSQL, objCnn, adOpenStatic, _
                adLockReadOnly, adCmdText

 
Old October 23rd, 2003, 01:30 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:You have to create the connection first before you open the recordset:
'Create connection object and open it
Set objCnn = Server.CreateObject ("ADODB.Connection")
objCnn.Open strConnect
Well, this not entirely true. You can pass a connection string to the Open method as well (see:
http://msdn.microsoft.com/library/de...mdamth03_2.asp for details):
Code:
recordset.Open Source, ActiveConnection, CursorType, LockType, Options

ActiveConnection 
Optional. Either a Variant that evaluates to a valid Connection 
object variable name, or a String that contains ConnectionString 
parameters.
But how does the rest of your code look like? A page not found is a bit odd. Are you redirecting away from the page when there is no record?

Maybe you need to enable detailed error messages for both the browser and the server. For your browser (IE), open the Internet options, and then the advanced tab. Disable "Show friendly http error messages"

You may also need to enable sending more detailed info from the server to the browser when an error occurs. What Web server are you using? Do you use an ISP or your own server?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Recordset empty when opening querydef DeAnzaJig Access VBA 3 November 14th, 2005 09:31 AM
How to get # of recs without opening recordset amjad_mahmood Excel VBA 0 August 9th, 2005 05:49 AM
form opening with where clause ginoitalo Access 4 December 22nd, 2004 09:16 PM
Opening A RecordSet Onyx2ir Access VBA 6 December 31st, 2003 12:46 AM
Trouble Opening Recordset NicholasM Classic ASP Databases 1 October 18th, 2003 04:03 PM





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