如何在 QTP 中对 Oracle 运行 SELECT 查询?
我遇到了一个困境,在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据提供程序/驱动程序、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.
这会直接打印表中的记录数。希望这有帮助。
This directly prints the count of records from ur table. hope this helps.