不包含动态 sql CommandType 的副作用?
运行动态 sql 调用时,如果不设置 cmd.CommandType 属性,可能会遇到哪些陷阱? 我无法使用 adovbs.inc,并且使用 cmd.CommandType = 200
会产生错误:
ADODB.Command (0x800A0BB9) 参数 类型错误,超出范围 可以接受的范围,或者有冲突 彼此之间。
因此,通过注释掉这一行,一切似乎都按计划进行。 但是,我可能会遇到哪些问题?
这是一段代码,用于上下文。
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = dbConn
cmd.CommandText = "SELECT * FROM Users WHERE active = 1 AND username=? AND password=?"
cmd.CommandType = 200 'advarchar
cmd.Parameters(0) = request.form("username")
cmd.Parameters(1) = request.form("password")
Dim RS
Set RS = cmd.Execute()
What pitfalls may I encounter by not setting the cmd.CommandType attribute when running a dynamic sql call? I can not use adovbs.inc, and using cmd.CommandType = 200
yields the error:
ADODB.Command (0x800A0BB9) Arguments
are of the wrong type, are out of
acceptable range, or are in conflict
with one another.
So by commenting this line out, everything appears to be working as planned. However, what issues may I run into?
Here is a snippet of the code, for context.
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = dbConn
cmd.CommandText = "SELECT * FROM Users WHERE active = 1 AND username=? AND password=?"
cmd.CommandType = 200 'advarchar
cmd.Parameters(0) = request.form("username")
cmd.Parameters(1) = request.form("password")
Dim RS
Set RS = cmd.Execute()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您
确定不想要
吗?
You have
Are you sure you don't want
instead?