Wrox Programmer Forums
|
ASP Forms As of Oct 5, 2005, this forum is now locked. Please use "Classic ASP beginner" at http://p2p.wrox.com/forum.asp?FORUM_ID=54 or "Classic ASP Professional" http://p2p.wrox.com/forum.asp?FORUM_ID=56 instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Forms 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 13th, 2004, 11:38 AM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default Type mismatch

Type mismatch

/includes/procurements-handler.asp, line 85

RS("IssueDate")=Request.Form("IssueDate")
This is line 85 above.

This is the text box from the form, do I need something to tell the sql database that is is a date?
<input type=text value="<%if Request.QueryString("ID") > 0 then%><%=RS("IssueDate")%><%end if%>" size=15 name=IssueDate>

The date is stored like this is in the database
1/5/2004

If someone could help that would be awesome


__________________
-----------------------------------------------------------
\"Don\'t follow someone who\'s not going anywhere\" John Mason
 
Old January 13th, 2004, 12:26 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try RS("IssueDate")=CDate(Request.Form("IssueDate"))

Dates are always quirky

Let me know if this helps

John

 
Old January 13th, 2004, 12:30 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks John, I didn't realise this at first but the problem is when a date isn't filled in I get a type mismatch error. Could it be that the field cannot except a null vaule or anything else but a date. If that is the case is there a way to allow it too accept a blank or a N/A for the date?

 
Old January 13th, 2004, 12:54 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try this

If isnull (Request.Form("Issue Date") then

RS("Issue Date")="NA"
else
RS("IssueDate")=CDate(Request.Form("IssueDate"))

End if

Be aware...if the format in the table is set to only accept dates you may have trouble inserting "NA"...it may still lead to type mismatch.

In the event the Issue date is left blank can you use today's date as a default?? If so try

If isnull (Request.Form("Issue Date") then

RS("Issue Date")=Date()
else
RS("IssueDate")=CDate(Request.Form("IssueDate"))

End if

Happy Programming.

Let me know if this helps


 
Old January 13th, 2004, 01:12 PM
Friend of Wrox
 
Join Date: Aug 2003
Posts: 166
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I still get a Type mismatch, using both. I guess field in the table would have to be changed, but I don't have access to the database. :-(
So I will just have to make sure a date is entered in the text box.
Thanks for your help

Also I get an error with the CDate
 
Old January 13th, 2004, 01:25 PM
Authorized User
 
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
Default

One last try
Try
RS("IssueDate")=FormatDateTime(Request.Form("Issue Date"),2)
2 is the vb reference to the vbShort Date format

John

 
Old January 13th, 2004, 04:23 PM
Authorized User
 
Join Date: Jun 2003
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

a guess:

there are checkfunctions to find out the subtype of the variant expression. IsObject, IsNumeric, IsArray, IsEmpty, IsNull (you used that one already), IsDate !

if IsDate(request.form("issuedate")) then
 rs("issuedate")=request.form("issuedate") '(with or without the CDate?)
else
 'keep track of the fact you have an error here and response.redirect at the end to recall the form
end if

?





Similar Threads
Thread Thread Starter Forum Replies Last Post
type mismatch frresh Pro Visual Basic 2005 1 April 11th, 2006 08:35 AM
Type Mismatch Anup Gavate VB How-To 4 March 28th, 2005 01:48 PM
Type mismatch NoBullMan Classic ASP Basics 2 November 16th, 2004 03:16 AM
Type mismatch per.holleufer Classic ASP Basics 5 July 31st, 2004 07:33 AM
Type mismatch sporkman43 Classic ASP Basics 4 August 14th, 2003 03:27 AM





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