如何使用DSN连接列出数据库的视图?

问题描述:

首先,我要告诉你,我工作的代码(VB6):如何使用DSN连接列出数据库的视图?

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 

,当我尝试列出数据库的意见,我得到了一个错误,指出: “厄尔尼诺proveedor没有puede ejecutar LA operaciònrequerida“(”提供商不能执行所需的操作“)

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

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

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

这是工作的代码:

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

我希望这可以帮助别人。

感谢您的阅读!