Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 November 17th, 2003, 05:42 AM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error Handling Question

Hi there

I'm using ASP and SQL Server.

Can anyone help me with the following quick query:

I've got an insert page with a textfield called 'date'. If I enter in a wrong date e.g. 30/02/2003 and press submit I get the following error on my process page:

ADODB.Command error '800a0d5d'

Application uses a value of the wrong type for the current operation.

Obviously my process page comes across this, runs the stored procedure but hits the 'date' problem.

I'd like to put a 'nice looking' error message that writes at the top of my insert page 'you've typed in a wrong date' but am not sure what ASP code I need to put on my process page.

Any ideas?

Thanks in advance.

Lucy


 
Old November 17th, 2003, 08:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Hi Lucy

Can't you use some asp and javascript?

For instance:

<%
    if varDate = "" then
%>
<script Language="Javascript">
    window.alert("You must enter a valid date.");
    history.go(-1);
</script>
<%
    else

...........the rest of your code

end if


hth

Adam
 
Old November 17th, 2003, 01:03 PM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

At the moment i've actually got 3 dropdowns for day, month, year. On my process page these get 'joined' together so that the stored procedure reads it as: day & "/" & month & "/" & year.

This then makes it a little more complicated doing your suggestion on the insert page, rather than the process page.

Any ideas?

Lucy

 
Old November 18th, 2003, 04:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

Right, so am I right in thinking that the sp will insert the date no matter whether it's valid or not at the moment?
 
Old November 18th, 2003, 05:32 AM
Authorized User
 
Join Date: Jul 2003
Posts: 56
Thanks: 0
Thanked 0 Times in 0 Posts
Default

No, it obviously gets to the 'insert date' bit of the stored procedure, knows it's wrong and puts the error:

ADODB.Command error '800a0d5d'

Application uses a value of the wrong type for the current operation.

/formhandlers/process_add.asp, line 184

which relates to the line:
Command1.Parameters.Append Command1.CreateParameter("@BDate", 135, 1,8,Command1__BDate)

I think, if I can't do what I want, i'm gonna have to change from 3 dropdown boxes to one textfield and then have the validation on the insert page.

Lucy


 
Old November 18th, 2003, 06:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

Why don't you validate the date on the insert page and only transfer to the processing page if the date is valid? If the date is invalid, stay on the insert page and write out some error message.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Error handling ppenn Access VBA 3 September 2nd, 2005 06:58 AM
Error Handling evad Excel VBA 2 August 18th, 2005 03:54 AM
Error Handling twbit BOOK: ASP.NET Website Programming Problem-Design-Solution 1 May 3rd, 2005 09:18 PM
Error Handling Louisa VB.NET 2002/2003 Basics 1 May 13th, 2004 10:22 AM
Error handling ! ittorget Classic ASP Professional 2 November 14th, 2003 09:44 AM





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