|
查看: 1095|回复: 4
|
ASP无法update mySQL资料
[复制链接]
|
|
|
- Dim conn, sConnection
- sConnection = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=localhost; DATABASE=mDB; UID=admin123;PASSWORD=admin123; option=3;Stmt=SET NAMES 'utf8';"
- set conn=Server.CreateObject("ADODB.Connection")
- conn.Open sConnection
- Dim MM_editCmd
- Set MM_editCmd = Server.CreateObject ("ADODB.Command")
- Set MM_editCmd.ActiveConnection = conn
- MM_editCmd.CommandText = "UPDATE tblRunningMsg SET Msg = ?, Hide = ? WHERE MsgID = ?"
- MM_editCmd.Prepared = true
- MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param1", 202, 1, 250, Request.Form("txtMsg")) ' adVarWChar
- MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param2", 5, 1, -1, MM_IIF(Request.Form("cbHide"), 1, 0)) ' adDouble
- MM_editCmd.Parameters.Append MM_editCmd.CreateParameter("param3", 5, 1, -1, MM_IIF(Request.Form("MM_recordId"), Request.Form("MM_recordId"), null)) ' adDouble
- MM_editCmd.Execute
- MM_editCmd.ActiveConnection.Close
复制代码
执行后出现错误,
Microsoft OLE DB Provider for ODBC Drivers error '80040e14' [MySQL][ODBC 3.51 Driver][mysqld-4.1.21-community-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE MsgID=22' at line 1
有人知道为什么吗?
[ 本帖最后由 和平 于 19-4-2008 04:45 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 19-4-2008 04:46 PM
|
显示全部楼层
就算用这个方法也出现同样的错误...
-
- Dim updateSQL
- updateSQL="UPDATE tblRunningMsg SET "
- updateSQL=updateSQL & "Msg='" & trim(Request.Form("txtMsg")) & "', "
- updateSQL=updateSQL & "Hide=" & MM_IIF(Request.Form("cbHide"), 1, 0) & ", "
- updateSQL=updateSQL & "WHERE MsgID=" & Request.Form("MM_recordId")
- conn.Execute updateSQL
复制代码 |
|
|
|
|
|
|
|
|
|
|
发表于 19-4-2008 05:01 PM
|
显示全部楼层
write 你的query出来看下where前面是不是多了个逗号(,)
还是where前面的value是空的。。 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 19-4-2008 05:08 PM
|
显示全部楼层
原帖由 Legend 于 19-4-2008 05:01 PM 发表 
write 你的query出来看下where前面是不是多了个逗号(,)
还是where前面的value是空的。。
第2个方法的确多了个(,) 去掉后没问题了.
但是为什么第1个方法就还是有问题... |
|
|
|
|
|
|
|
|
|
|
发表于 19-4-2008 05:30 PM
|
显示全部楼层
|
可能Hide=(没有value) 所以就有error...response.write 你的 query 出来看看。。。 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|