Forums

ASP

This topic is locked

Problems with SQL parameters in ASP

Posted 21 Mar 2008 15:19:12
1
has voted
21 Mar 2008 15:19:12 paul wheatley posted:
Hello,

I have recently moved away from the simple SQL INSERTS such as

sql="UPDATE TBLpages SET page_text='"&request.form("editor1"&"' WHERE pageUID="&request.querystring("UID"&" AND deptID_FK = "&(siteid)&""

So i am using the following style...

MM_editCmd.CommandText = "UPDATE TBLpages SET page_text = ?, deptID_FK = ?, pageUID = ?, WHERE [UID] = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 203, 1, 1073741823, Request.Form("editor1") ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("dept", Request.Form("dept", null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("UID", Request.Form("UID", null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 5, 1, -1, MM_IIF(Request.Form("MM_recordId", Request.Form("MM_recordId", null)) ' adDouble

Which works great, but i needed to add in a hidden field containing the date, to provide the entry with a hidden datestamp, so i changed the code to the following...

MM_editCmd.CommandText = "UPDATE TBLpages SET page_text = ?, deptID_FK = ?, pageUID = ?, Last_Update = ? WHERE [UID] = ?"
MM_editCmd.Prepared = true
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 203, 1, 1073741823, Request.Form("editor1") ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("dept", Request.Form("dept", null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("UID", Request.Form("UID", null)) ' adDouble
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param4", 203, 1, 1073741823, Request.Form("Last_Update") ' adLongVarWChar
MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param5", 5, 1, -1, MM_IIF(Request.Form("MM_recordId", Request.Form("MM_recordId", null)) ' adDouble

and now i am getting this error message

Microsoft OLE DB Provider for SQL Server error '80040e07'

Operand type clash: ntext is incompatible with smalldatetime

/a_depts/DEVELOPMENTv2_02/edit_page.asp, line 43

I think this is because i am using the wrong parameters for a date field
("param4", 203, 1, 1073741823,)
for my SQL but i can't find anything in the internet that tells what the parameters should be.

Please help i am pulling my hair out with this one!

Paul

Replies

Replied 22 Mar 2008 05:10:19
22 Mar 2008 05:10:19 Javier Castro replied:
have you tried inserting the date as text instead of a smalldatetime?
I had similar issue with a migration from AccessDB to SQL, I did that and worked nicely.

hope it helps.

Javier
"I'm a slow learner and I forget fast" grandpa
DW | FW | ASP | HTML | CSS

Reply to this topic