如何在 QTP 中对 Oracle 运行 SELECT 查询?

发布于 2024-12-20 15:06:49 字数 537 浏览 6 评论 0原文

我遇到了一个困境,在 Benthic Golden32 (或其他数据库连接软件)中运行良好的查询不会在 QTP 中返回任何值。作为我正在运行的代码的示例:

set conn=CreateObject("ADODB.Connection") 
conn.ConnectionString ="Driver={Microsoft ODBC for Oracle};Server=SERVER;uid=USER;pwd=123456;" 
Set objRecSet = CreateObject("ADODB.Recordset")
conn.open
SQL= "SELECT * FROM table"
objRecSet.Open SQL, conn

msgbox(objRecSet.RecordCount)

这将返回 -1。为什么?我在 Benthic 和 QTP 中使用相同的用户帐户,并在两种情况下运行相同的查询。在 QTP 中对同一帐户和表进行 INSERT 查询工作正常。

感谢您提前的帮助!

I have a dilemma, where a query that works fine in Benthic Golden32 (or other database connection software) does not return any values in QTP. As an example of the code I'm running:

set conn=CreateObject("ADODB.Connection") 
conn.ConnectionString ="Driver={Microsoft ODBC for Oracle};Server=SERVER;uid=USER;pwd=123456;" 
Set objRecSet = CreateObject("ADODB.Recordset")
conn.open
SQL= "SELECT * FROM table"
objRecSet.Open SQL, conn

msgbox(objRecSet.RecordCount)

This returns -1. Why? I am using the same user account in both Benthic and QTP and running the same query in both cases. INSERT queries in QTP on the same account and table work fine.

Thanks for the help in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽清梦 2024-12-27 15:06:50

根据提供程序/驱动程序、CursorType 和月相,.RecordCount 无法在循环结果集之前提供记录数。 此处开始您的研究;检查 ADO 文档中两个 .Open 方法的附加参数;考虑切换到“SELECT COUNT”类型的查询来查看有多少行。

Depending on the provider/driver, the CursorType, and the phase of the moon, .RecordCount can't give you the number of records before you looped over the resultset. Start your research here; check the additional parameters to both .Open methods in the ADO Docs; consider to switch to a "SELECT COUNT" type of query to see how many rows you got.

舟遥客 2024-12-27 15:06:50
sqlStatement = "select count(*) from emp"
Rec.Open sqlStatement,conn
Value = Rec.fields.item(0)
     msgbox Value

这会直接打印表中的记录数。希望这有帮助。

sqlStatement = "select count(*) from emp"
Rec.Open sqlStatement,conn
Value = Rec.fields.item(0)
     msgbox Value

This directly prints the count of records from ur table. hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文