原始 C++使用 OLE DB 显示 SQL 紧凑型服务器中表名称的代码
有没有人有给定数据库文件显示所有用户表名称的示例代码?
我对 .NET 代码不感兴趣,只对 C++ 感兴趣。
我正在尝试使用 OLE DB 来完成任务 - 相比之下,火箭科学似乎是小儿科。
Does anyone have a sample code that given the database file displays the names of all the user tables there?
I am not interested in a .NET code, just the C++.
I am trying to grok OLE DB to do the task - rocket science seems child play in comparison.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将假设 SQL Server CE 3.0/3.1,但为了供您参考,以下是我所知道的提供程序字符串:
另外,我将为您提供两个代码示例:
我以 C++ 控制台应用程序的形式向您提供示例,并使用 ATL 来简化代码。该代码完整且可以工作,但不包括对 HRESULT hr 进行必要的错误检查。
以下是用于查询 SQL Server CE 3.0/3.1 数据库以使用 ICommandText 和 IRowset 执行“SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES”的 C++ 控制台应用程序示例:
以下是用于查询 SQL Server CE 3.0/3.1 数据库以浏览 SQL Server CE 3.0/3.1 数据库的 C++ 控制台应用程序示例使用 IDBSchemaRowset 和 IRowset 的表(请注意,TABLE_NAME 现在位于 iOrdinal 3 而不是1):
I'm going to assume SQL Server CE 3.0/3.1 but, for your reference, here are provider strings I'm aware of:
Also, I will be providing you with two code examples:
I'm providing you the samples as C++ console application and have used ATL to make the code short. The code is complete and working but does not include the necessary error checking of the HRESULT hr.
Here's the C++ console application sample for querying a SQL Server CE 3.0/3.1 database for executing "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES" using ICommandText and IRowset:
Here's the C++ console application sample for querying a SQL Server CE 3.0/3.1 database for browsing the tables using IDBSchemaRowset and IRowset (note that TABLE_NAME is now at iOrdinal 3 instead of 1):