1

首先,我想向您展示我正在处理的代码(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

当我尝试列出数据库的视图时,我收到一条错误消息:“Elproveedor no puede ejecutar la operaciòn requerida”(“Provider can't execute the required operation”)

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

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

4

1 回答 1

0

我找到了!在 DSN 连接中,视图和表都被视为表。

这是有效的代码:

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

我希望这可以帮助某人。

谢谢阅读!

于 2010-10-25T17:09:48.997 回答