如何使用 OLEDB API 获取给定 SQL Server Compact Edition 数据库文件 (.sdf) 的版本?
我的 C++ 应用程序需要处理属于不同版本的 SSCE 数据库文件。目前,我无法知道数据库的版本。
问题是,如果 OLEDB SSCE 提供程序的版本与数据库文件的版本不匹配,IDBInitialize::Initialize()
将失败并显示 E_FAIL
。必须获取相应的 IErrorInfo
对象才能获得有意义的错误消息。
关键是,E_FAIL
的错误代码并没有告诉我失败是因为版本不匹配还是其他原因。在第一种情况下,我应该使用另一个 SSCE 提供程序重试,而在第二种情况下,应用程序应该终止。
我该如何实现这个逻辑?在调用 IDBInitialize::Initialize() 之前是否可以调用一些 API 来检查版本兼容性?有没有办法获取真正的错误代码而不是不透明的 E_FAIL
?
谢谢。
My C++ app needs to deal with SSCE database files belonging to different versions. Right now, I have no way of knowing the version of the database.
The problem is that if the version of the OLEDB SSCE provider mismatches the version of the database file, IDBInitialize::Initialize()
fails with E_FAIL
. One has to obtain the respesctive IErrorInfo
object to get a meaningful error message.
The point is that the error code of E_FAIL
does not tell me whether the failure is because of the version mismatch or for some other reason. In the first case, I should retry with another SSCE provider, while in the second the application should terminate.
How can I implement this logic? Is there some API that I can invoke before calling IDBInitialize::Initialize()
to check the version compatibility? Is there a way to get the real error code instead of the opaque E_FAIL
?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以查看文件的第一个字节 - 请参阅 C# 示例 - http://erikej.blogspot.com/2010/08/how-to-upgrade-version-3x-database-file.html
You can look at the first bytes of the file - see this sample in C# - http://erikej.blogspot.com/2010/08/how-to-upgrade-version-3x-database-file.html