如何列出具有 DSN 连接的数据库的视图?

发布于 2024-09-29 03:19:00 字数 617 浏览 3 评论 0原文

首先,我想向您展示我正在处理的代码(VB6):

Dim db as Connection
Dim rs as Recordset
Dim rs1 as Recordset

db.Open "DSN=myDSN; Uid=myUser; Pwd=myPassword;"

'I connect successfully

Set rs = db.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
' Everything ok here. I can list Database tables

Set rs1 = db.OpenSchema(adSchemaViews)  'This is the line I have problems with

当我尝试列出数据库的视图时,我收到一条错误消息: “El Proedor no puede ejecutar la operaciòn requerida”(“提供商无法执行所需的操作”)

我配置了一个可以使用密码访问 BD 的用户。当我使用连接字符串连接到相同的数据库时,我可以列出 Oracle 和 SqlServer 中的表和视图。

我错过了什么吗?数据库引擎中的配置选项。或许?

First, I want to show you the code I'm working on (VB6):

Dim db as Connection
Dim rs as Recordset
Dim rs1 as Recordset

db.Open "DSN=myDSN; Uid=myUser; Pwd=myPassword;"

'I connect successfully

Set rs = db.OpenSchema(adSchemaTables, Array(Empty, Empty, Empty, "TABLE"))
' Everything ok here. I can list Database tables

Set rs1 = db.OpenSchema(adSchemaViews)  'This is the line I have problems with

when I try to list the Database's views I got an error that says:
"El proveedor no puede ejecutar la operaciòn requerida" ("Provider can't execute the required operation")

I configured an user that can access the BD it with a password. When I connect to the same Databases using a connection string I can list both tables and views in both Oracle and SqlServer.

Am I missing something? A configuration option in the databases Engines. maybe?

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

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

发布评论

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

评论(1

纸伞微斜 2024-10-06 03:19:00

我找到了!从 DSN 连接来看,视图和表都被视为表。

这是有效的代码:

Set rs1 = db.OpenSchema(adSchemaTables)
If rs1("TABLE_TYPE").Value = "VIEW" Then
' Do a lot of things with the views :D
End If

我希望这可以帮助别人。

感谢您的阅读!

I Found it! From a DSN connection, both Views and Tables are considerer as Tables.

This is the code that works:

Set rs1 = db.OpenSchema(adSchemaTables)
If rs1("TABLE_TYPE").Value = "VIEW" Then
' Do a lot of things with the views :D
End If

I hope this can help somebody.

Thanks for reading!

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