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 January 26th, 2005, 07:18 AM
cpk cpk is offline
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Need some error trapping...

I am looking for some error trapping code to help me... Problem is that the RequestName is not always in the database so throws up an error. Is there a way to display a nice error?

MyCode:
select * from CPD where Name = "&RequestName&" Order By DateAdded DESC

sorry for being so thick and thanks
ck

 
Old January 26th, 2005, 07:32 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

What sort of error are you getting? It looks like you just need to check whether your query returns a record or not.

Cheers,

Chris
 
Old January 26th, 2005, 07:51 AM
cpk cpk is offline
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes thats what i need... Here is the error anyway:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Line 1: Incorrect syntax near 'Joe Bloggs'.

standard error message
thanks
ck

 
Old January 26th, 2005, 08:02 AM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is your name field a VARCHAR? If so, change the query to:
Code:
"select * from CPD where Name = '" & RequestName & "' Order By DateAdded DESC;"
I would also replace any single quotes within RequestName with a pair of single quotes.

HTH,

Chris

 
Old January 26th, 2005, 08:10 AM
cpk cpk is offline
Registered User
 
Join Date: Jan 2005
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Bingo that did it!

Cheers Chris






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP Error Trapping and Reporting kevorkian Classic ASP Basics 3 June 2nd, 2007 02:08 PM
error trapping majones@omaha Classic ASP Basics 0 January 5th, 2006 02:02 PM
Trapping Application Events ERROR MagicTH Excel VBA 1 August 14th, 2005 01:23 PM
Error Trapping Steps jweyl SQL Server DTS 1 July 26th, 2004 05:59 PM





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