adodb.command的问题

ppt2000 2006-05-23 11:53:32
一个页面,一个command对象,cmd
首先执行一个存储过程,添加了若干个parameter,执行成功

然后
未执行set cmd=nothing
将cmd的commandtext改为另一个存储过程
添加parameter
执行,出错,说是parameter太多,输出了一下,发现上一个存储过程的parameter也在

在两次执行之间加入
set cmd=nothin
set cmd=server.createobject("adodb.command")
两者都执行成功。


如此,是否执行了1之后要清除parameter?如何清除?
command执行完之后如何清理,只有set cmd=nothing么?
...全文
164 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
ppt2000 2006-06-16
  • 打赏
  • 举报
回复
?
ppt2000 2006-05-27
  • 打赏
  • 举报
回复
?
是是非非 2006-05-23
  • 打赏
  • 举报
回复
cmd.Parameters.Remove("@Par1")
cmd.Parameters.Remove("@Par2")
ppt2000 2006-05-23
  • 打赏
  • 举报
回复
必须要去除么?
部分源代码: Private Sub Command1_Click() Dim sql As String Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sql = "select * from book where [图书编码]= ? " If Command1.Caption = "添加记录" Then Command1.Caption = "确 定" Command2.Enabled = False '屏蔽删除、修改、下一记录、上一记录按钮,避免出现数据库错误 Command3.Enabled = False Command4.Enabled = False cmdmodify.Enabled = False rst.AddNew Else If Text1.Text = "" Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "图书编号不能为空!" Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sql cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此书号已经存在!" rst.Cancel Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True cmdmodify.Enabled = True Command1.Caption = "添加记录" Command2.Enabled = True Exit Sub End If rst.Update Command2.Enabled = True '数据库更新结束后才可以点击其他几个按钮 Command3.Enabled = True Command4.Enabled = True cmdmodify.Enabled = True Command1.Caption = "添加记录" End If End Sub 修改图书记录操作 Private Sub cmdmodify_Click() '修改记录按钮 Dim sqlstr As String Dim rst1 As New ADODB.Recordset Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sqlstr = "select * from book where [图书编码]= '" & Trim(Text1.Text) & "'" With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sqlstr cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此书号已经存在!" rst.Cancel Exit Sub End If rst.Update frmMsg.Show frmMsg.info.Visible = True frmMsg.Text1.Text = "修改成功!" End Sub 添加职工信息 Private Sub Command1_Click() '添加记录 Dim sql As String Dim param As ADODB.Parameter Dim cmd As ADODB.Command Set cmd = New ADODB.Command Set param = New ADODB.Parameter sql = "select * from worker where [工号]= ? " If Command1.Caption = "添加记录" Then Command1.Caption = "确 定" Command2.Enabled = False Command3.Enabled = False Command4.Enabled = False rst.AddNew Else If Text1.Text = "" Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "职工编号不能为空!" Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If With param .Direction = adParamInput .Type = adBSTR .Size = 8 .Value = Text1.Text End With cmd.Parameters.Append param cmd.CommandText = sql cmd.CommandType = adCmdText Set cmd.ActiveConnection = con Set rst1 = cmd.Execute '检测职工编号是否存在防止主键冲突 If rst1.RecordCount > 0 Then frmMsg.Show frmMsg.notice.Visible = True frmMsg.Text1.Text = "此职工编号已经存在!" rst.Cancel Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" Exit Sub End If rst.Update Command2.Enabled = True Command3.Enabled = True Command4.Enabled = True Command1.Caption = "添加记录" End If End Sub

28,390

社区成员

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

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