我在尝试通过参数调用将服务器日期插入数据库时遇到了一些麻烦,我在此操作的代码如下所示:
<%
If (CStr(Request("MM_insert")) = "Modal-Menu-AddNote-Form") Then
If (Not MM_InsertEdit) Then
' execute the insert
Dim MM_InsertCmd
Set MM_InsertCmd = Server.CreateObject ("ADODB.Command")
MM_InsertCmd.ActiveConnection = MM_Logistics_STRING
MM_InsertCmd.CommandText = "INSERT INTO Notes (Note_Text, Note_Date) VALUES (?, ?)"
MM_InsertCmd.Prepared = true
MM_InsertCmd.Parameters.Append MM_InsertCmd.CreateParameter("param1", 202, 1, 255, Request.Form("Modal-Menu-Paragraph-AddNote")) ' adVarWChar
MM_InsertCmd.Parameters.Append MM_InsertCmd.CreateParameter("param2", 135, 0, -1, Date) ' adDBTimeStamp
MM_InsertCmd.Execute
MM_InsertCmd.ActiveConnection.Close
' append the query string to the redirect URL
Dim MM_InsertRedirectUrl
MM_InsertRedirectUrl = "edit.asp"
If (Request.QueryString <> "") Then
If (InStr(1, MM_InsertRedirectUrl, "?", vbTextCompare) = 0) Then
MM_InsertRedirectUrl = MM_InsertRedirectUrl & "?" & Request.QueryString
Else
MM_InsertRedirectUrl = MM_InsertRedirectUrl & "&" & Request.QueryString
End If
End If
Response.Redirect(MM_InsertRedirectUrl)
End If
End If
%>
注意“param2”行是很重要的,因为这是我试图将日期插入数据库的区域,我也尝试过(0-Unknown,1-In,2-out,3-In / out)对于第三个参数但我仍然得到错误,例如参数类型错误,超出可接受的范围,或彼此冲突,或无效的字符串或缓冲区长度。关于如何解决这个问题的任何想法或想法?
答案 0 :(得分:0)
此问题最终被重新开发,最终成为我收集数据的文本区域的问题。结束帖,谢谢大家的帮助和建议。