从 ADODB 获取受影响的行数ASP 与 JScript
我们正在使用 MS-SQL7.0、ASP(带有 Jscript) 查询和执行没有任何问题。 但我们遇到了影响记录计数的问题。 我们参考此来源
http://support.microsoft.com/kb/195048
这里是我们的源代码
var query = "...";
this.db = Server.CreateObject("ADODB.Connection");
this.db.Open(this.connectionString);
this.db.Execute(query, this.rowCount);
Response.Write(this.rowCount);
or
var query = "...";
this.db = Server.CreateObject("ADODB.Connection");
this.cmd = Server.CreateObject("ADODB.Command");
this.cmd.ActiveConnection = this.db;
this.cmd.CommandText = query;
this.cmd.Execute(this.rowCount);
Response.Write(this.rowCount);
但是这个代码不起作用,rowCount
被设置为其初始值(0)。 我认为这是因为 javascript 中的原始类型总是按值调用。
Possible Duplicate:
How can I get the # of rows affected by a statement using ADO with JavaScript?
We're using MS-SQL7.0, ASP(with Jscript)
there isn't any problem in querying and executing.
But we faced an problem getting affected record count.
We refer to this source
http://support.microsoft.com/kb/195048
Here is our source code
var query = "...";
this.db = Server.CreateObject("ADODB.Connection");
this.db.Open(this.connectionString);
this.db.Execute(query, this.rowCount);
Response.Write(this.rowCount);
or
var query = "...";
this.db = Server.CreateObject("ADODB.Connection");
this.cmd = Server.CreateObject("ADODB.Command");
this.cmd.ActiveConnection = this.db;
this.cmd.CommandText = query;
this.cmd.Execute(this.rowCount);
Response.Write(this.rowCount);
But this code don't work, rowCount
are set to its initial value(0).
I think it because primitive type in javascript is always called by value.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
过去,我在这种情况下尝试过两种方法(我同意,有点粗糙。)。
1。混合语言
2。 RDBMS 功能可能很有用。(您做到了)
In the past I've tried two methods in such a case (I agree, a little bit scratchy.).
1. Mixing languages
2. RDBMS features can be useful. (you did this)
ActiveX 数据对象 (ADO) 命令对象的 Execute 方法通过引用传递一个整数值,您可以使用该值来检索受 SQL UPDATE 命令影响的记录数。
http://support.microsoft.com/kb/195048
The Execute method of the ActiveX Data Objects (ADO) Command object passes by reference an integer value that you can use to retrieve the number of records affected by a SQL UPDATE command.
http://support.microsoft.com/kb/195048