添加删除命令时,出现错误ADODB.Command (0x800A0D5D)

sddaixin 2012-05-17 04:08:13
请尝试执行下列操作:

单击刷新按钮,或稍后重试。

打开 localhost 主页,然后查找与所需信息相关的链接。
HTTP 错误 500.100 - 内部服务器错误 - ASP 错误
Internet 信息服务

--------------------------------------------------------------------------------

技术信息(用于支持人员)

错误类型:
ADODB.Command (0x800A0D5D)
应用程序在当前操作中使用了错误类型的值。
/admin_ht/ly_gl.asp, 第 30 行


浏览器类型:
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)

网页:
GET /admin_ht/ly_gl.asp

时间:
2012年5月17日, 15:37:14


详细信息:
Microsoft 支持



以下是本页全代码
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Connections/conn.asp" -->
<%
' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse
Else
MM_IIf = ifTrue
End If
End Function
%>
<%
Dim Recordset1
Dim Recordset1_cmd
Dim Recordset1_numRows

Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_conn_STRING
Recordset1_cmd.CommandText = "SELECT * FROM liuyan_biao ORDER BY lytime DESC"
Recordset1_cmd.Prepared = true

Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0
%>
<%

Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = "DELETE FROM liuyan_biao WHERE lyid = ?"
Command1.Parameters.Append Command1.CreateParameter("a", 3, 1, -1, MM_IIF(request("lyid"), request("lyid"), Command1__a & "")) 这是出错行!
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

%>

<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 10
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<%
' *** Recordset Stats, Move To Record, and Go To Record: declare stats variables

Dim Recordset1_total
Dim Recordset1_first
Dim Recordset1_last

' set the record count
Recordset1_total = Recordset1.RecordCount

' set the number of rows displayed on this page
If (Recordset1_numRows < 0) Then
Recordset1_numRows = Recordset1_total
Elseif (Recordset1_numRows = 0) Then
Recordset1_numRows = 1
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last = Recordset1_first + Recordset1_numRows - 1

' if we have the correct record count, check the other stats
If (Recordset1_total <> -1) Then
If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total
End If
If (Recordset1_numRows > Recordset1_total) Then
Recordset1_numRows = Recordset1_total
End If
End If
%>

<%
' *** Recordset Stats: if we don't know the record count, manually count them

If (Recordset1_total = -1) Then

' count the total records by iterating through the recordset
Recordset1_total=0
While (Not Recordset1.EOF)
Recordset1_total = Recordset1_total + 1
Recordset1.MoveNext
Wend

' reset the cursor to the beginning
If (Recordset1.CursorType > 0) Then
Recordset1.MoveFirst
Else
Recordset1.Requery
End If

' set the number of rows displayed on this page
If (Recordset1_numRows < 0 Or Recordset1_numRows > Recordset1_total) Then
Recordset1_numRows = Recordset1_total
End If

' set the first and last displayed record
Recordset1_first = 1
Recordset1_last = Recordset1_first + Recordset1_numRows - 1

If (Recordset1_first > Recordset1_total) Then
Recordset1_first = Recordset1_total
End If
If (Recordset1_last > Recordset1_total) Then
Recordset1_last = Recordset1_total
End If

End If
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
body,td,th {
font-size: 12px;
}
-->
</style></head>

<body>
<h3><a href="ly_gl.asp">留言管理</a></h3>
<p> </p>
<table width="100%" border="1" cellspacing="0" cellpadding="6">
<tr align="center">
<td colspan="8"><strong>管理现有留言(共<%=(Recordset1_total)%>条留言)</strong></td>
</tr>
<tr align="center">
<td align="center"><strong>姓名</strong></td>
<td align="center"><strong>联系电话</strong></td>
<td align="center"><strong>留言内容</strong></td>
<td align="center"><strong>联系地址</strong></td>
<td align="center"><strong>审核</strong></td>
<td align="center"><strong>回复</strong></td>
<td align="center"><strong>修改</strong></td>
<td align="center"><strong>删除</strong></td>
</tr>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<tr>
<td align="center"><%=(Recordset1.Fields.Item("lyxm").Value)%></td>
<td align="center"><%=(Recordset1.Fields.Item("lxdh").Value)%></td>
<td align="center"><%=(Recordset1.Fields.Item("lynr").Value)%></td>
<td align="center"><%=(Recordset1.Fields.Item("lxdz").Value)%></td>
<td align="center"><%=(Recordset1.Fields.Item("sh").Value)%></td>
<td align="center">回复</td>
<td align="center">修改</td>
<td align="center"><a href="ly_gl.asp?type=del&lyid=<%=(Recordset1.Fields.Item("lyid").Value)%>">删除</a></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
</table>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
...全文
247 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sddaixin 2012-05-17
  • 打赏
  • 举报
回复
哎,愁死了,弄了一下午也没弄好,从别的网页粘贴过来的代码就好了,不知道这两个有什么区别!


<% If Trim(Request.QueryString("type"))<>"" Then %>
<%

Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = "DELETE FROM liuyan_biao WHERE lyid = ?"
Command1.Parameters.Append Command1.CreateParameter("a", 3, 1, -1, MM_IIF(request("lyid"), request("lyid"), Command1__a & ""))
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()

%>
<script>
alert("删除成功!")
window.location.href="ly_gl.asp"
</script>
<% End If %>

后面加上提示代码
<td align="center"><a href="ly_gl.asp?type=del&lyid=<%=(Recordset1.Fields.Item("lyid").Value)%>"onclick="javascript:return p_del()">删除</a></td> </tr>
<SCRIPT LANGUAGE=javascript>

function p_del() {
var msg = "您确定要删除吗?";
if (confirm(msg)==true){
return true;
}else{
return false;
}
}

</SCRIPT>
qq734466602 2012-05-17
  • 打赏
  • 举报
回复
参数不对,或者重新建立网页
sddaixin 2012-05-17
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
Command1.CreateParameter("a", 3, 1, -1, CINT(MM_IIF(request("lyid"), request("lyid"),0))
[/Quote]

还是不行呢,出现了下面的错误:

错误类型:
Microsoft VBScript 编译器错误 (0x800A03EE)
缺少 ')'
/admin_ht/ly_gl.asp, line 32, column 89
Command1.CreateParameter("a", 3, 1, -1, CINT(MM_IIF(request("lyid"), request("lyid"),0)) Command1__a & ""
----------------------------------------------------------------------------------------^
snlixing 2012-05-17
  • 打赏
  • 举报
回复
Command1.CreateParameter("a", 3, 1, -1, CINT(MM_IIF(request("lyid"), request("lyid"),0))
sddaixin 2012-05-17
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]
CreateParameter 里指定3,说明是整型,MM_IIf里返回的是字符串。要做类型转换
CInt(MM_IIf(request("lyid"),request("lyid"), 0))

----
是什么?
[/Quote]
我也不知道,那个Command1__a是什么,a是我设置的一个删除时候的变量
现在我改成了 CInt(MM_IIf(request("lyid"),request("lyid"), 0))
还是出现了下面的错误:
错误类型:
Microsoft VBScript 编译器错误 (0x800A03EE)
缺少 ')'
/admin_ht/ly_gl.asp, line 30, column 114
Command1.Parameters.Append Command1.CreateParameter("a", 3, 1, -1, CINT(MM_IIF(request("lyid"), request("lyid"),0)
-----------------------------------------------------------------------------------------------------------------^
各位大侠再帮忙看一下,谢谢了
hookee 2012-05-17
  • 打赏
  • 举报
回复
CreateParameter 里指定3,说明是整型,MM_IIf里返回的是字符串。要做类型转换
CInt(MM_IIf(request("lyid"),request("lyid"), 0))

----
Command1__a是什么?
sddaixin 2012-05-17
  • 打赏
  • 举报
回复
期盼各位大侠指正!在线等,谢谢了
sddaixin 2012-05-17
  • 打赏
  • 举报
回复
参数 LYID这个应该是对的,在ACCESS里面字段类型是“自动编号”型的
三石-gary 2012-05-17
  • 打赏
  • 举报
回复
Command1.Parameters.Append Command1.CreateParameter("a", 3, 1, -1, MM_IIF(request("lyid"), request("lyid"), Command1__a & ""))
分别看看你传的参数对不对。。

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧