|
Subject:
|
Type mismatch
|
|
Posted By:
|
morpheus
|
Post Date:
|
1/13/2004 10:38:01 AM
|
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
|
|
Reply By:
|
jrwlkn
|
Reply Date:
|
1/13/2004 11:26:04 AM
|
Try RS("IssueDate")=CDate(Request.Form("IssueDate"))
Dates are always quirky
Let me know if this helps
John
|
|
Reply By:
|
morpheus
|
Reply Date:
|
1/13/2004 11:30:01 AM
|
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?
|
|
Reply By:
|
jrwlkn
|
Reply Date:
|
1/13/2004 11:54:18 AM
|
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
|
|
Reply By:
|
morpheus
|
Reply Date:
|
1/13/2004 12:12:04 PM
|
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
|
|
Reply By:
|
jrwlkn
|
Reply Date:
|
1/13/2004 12:25:54 PM
|
One last try Try RS("IssueDate")=FormatDateTime(Request.Form("IssueDate"),2) 2 is the vb reference to the vbShort Date format
John
|
|
Reply By:
|
mndrx
|
Reply Date:
|
1/13/2004 3:23:28 PM
|
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
?
|