Forum Moderators: open

Message Too Old, No Replies

Type mismatch: 'cdate'

         

vanjamier

5:44 am on Feb 16, 2005 (gmt 0)

10+ Year Member



Hi, i have the following error

Error Type:
Microsoft VBScript runtime (0x800A000D)
Type mismatch: 'cdate'
/webapps/telecost/mobile/secured/update_data.asp, line 60

i do not understand why it is mismatch because i declare 2 other variables
and those were not higlighted.


<!-- #include file="include/connections/database.inc" -->
<!-- #include file="include/alldateformat.inc" -->
<HTML>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
dim strdate1
on error goto 0
'Fetch the name of this script
ScriptName = Request.ServerVariables("SCRIPT_NAME")
'open the database from database.inc file
OpenDatabase()
'QueryStrings
strName = Request.QueryString("NAME") 'variables
strName2 = Request.Form("Name")
strLogin = Request.Form("LoginId")
strLogin2 = Request.Form("LoginId2")
strdepartment = Request.Form("department")
strcentre = Request.Form("costcentre")
strphone = Request.Form("phoneno")
strmodel = Request.Form("model")
strimei = Request.Form("imei")
strwarranty = Request.Form("warranty")
strdate1 = Request.Form("sim")
strdate2 = Request.Form("handphone")
strsingtelac = Request.Form("singtelac")
strplantype = Request.Form("plantype")
strsingone = Request.Form("singone")
strsingtwo = Request.Form("singtwo")
strelectric = Request.Form("electriclink")
strnolines = Request.Form("nolines")
strmarks = Request.Form("remarks")

If Request.form("btnEdit") = "Update Record" Then

Set rs = Server.CreateObject("ADODB.RecordSet")

'Sim Date
strdate1 = cdate(strdate1)
strsimday= DanDate(strdate1, "%d")
strsimmonth= DanDate(strdate1, "%b")
strsimyear = DanDate(strdate1, "%Y")
Strsimdate = strsimday + " " +strsimmonth+ " " + strsimyear

'hp date
strdate2 = cdate(strdate2)
strhpday= DanDate(strdate2, "%d")
strhpmonth= DanDate(strdate2, "%b")
strhpyear = DanDate(strdate2, "%Y")
Strhpdate = strhpday + " " +strhpmonth+ " " + strhpyear

'singtelone date
strsingone = cdate(strsingone) This is the error line
strsingoneday= DanDate(strsingone, "%d")
strsingonemonth= DanDate(strsingone, "%b")
strsingoneyear = DanDate(strsingone, "%Y")
Strsingonedate = strsingoneday + " " +strsingonemonth+ " " + strsingoneyear

'electriclink date
strelectric = cdate(strelectric)
strelectricday= DanDate(strelectric, "%d")
strelectricmonth= DanDate(strelectric, "%b")
strelectricyear = DanDate(strelectric, "%Y")
Strelectricdate = strelectricday + " " +strelectricmonth+ " " + strelectricyear

'strsingtwo date
strsingtwo = cdate(strsingtwo)
strsingtwoday = DanDate(strsingtwo, "%d")
strsingtwomonth = DanDate(strsingtwo, "%b")
strsingtwoyear = DanDate(strsingtwo, "%Y")
Strsingtwodate = strsingtwoday + " " +strsingtwomonth+ " " + strsingtwoyear

'update record
strsql= "Update sunder.mobile_users set" _
& " DEPT = '" & strdepartment & "', " _
& " COST_CENTRE = '" & strcentre & "', " _
& " PHONE_NO = '" & strphone & "', " _
& " MODEL = '" & strmodel & "', " _
& " IMEI = '" & strimei & "', " _
& " DATE_OF_PURCHASE = to_date('" & Strsimdate & "','DD/MM/YYYY'), " _
& " REMARKS = '" & strmarks & "', " _
& " WARRANTY_CARD = '" & strwarranty & "', " _
& " HP_DATE_OF_PURCHASE = to_date('" &Strhpdate& "','DD/MM/YYYY'), " _
& " SINGTEL_ACCOUNT_NO = '" & strsingtelac & "', " _
& " PLAN_TYPE = '" & strplantype & "', " _
& " SINGTEL_ONE_YR = to_date('" &Strsingonedate& "','DD/MM/YYYY'), " _
& " ELECTRICLINK_TWO_YR = to_date('" &Strelectricdate& "','DD/MM/YYYY'), " _
& " SINGTEL_TWO_YR = to_date('" & Strsingtwodate & "','DD/MM/YYYY'), " _
& " MOBILE_LINE = " & strnolines & ", " _
& " LOGINID = '" & strLogin & "', " _
& " LOGINTYPE = '" & strLogin2 & "' " _
& " Where NAME = '" & strName & "'"

rs.Open strsql, conn

Response.Write "<font color=""green"">Record was successfully updated..."
Response.Write "</font>"
Response.Write "<br>"
Response.Write "<A href=""admin_view.asp"">Click here to continue.."
End If
%>
</BODY>
</HTML>
any help will be appreciated.
thanks

mattglet

1:10 pm on Feb 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your strsingone variable is not in correct date format, nor is in any format that can be easily converted into date. You need to do format validation BEFORE you use CDate().

For example:
Your strsingone variable might contain the value: 123a45. This would throw the error if you tried to use CDate(). Create some functionality that will check the value first. You could even use IsDate().