使用 CDynamicAccessor 连接数据库时如何判断列是 text 还是 ntext?
我有一个 C++ 应用程序使用 CDynamicAccessor 连接到 MS SQL Server 2005。 当我的列是 text 或 ntext 时,CDynamicAccessor::GetColumnType 始终返回 DBTYPE_IUNKNOWN。我可以将数据绑定为 ISequentialStream 并读取字节流。但是,我如何判断我正在读取的列是 text 还是 ntext,从而将字节流解释为 ASCII 还是 Unicode?
I'm having a C++ application connecting to the MS SQL Server 2005 using CDynamicAccessor.
When my column is text or ntext, the CDynamicAccessor::GetColumnType always return DBTYPE_IUNKNOWN. I can bind the data as ISequentialStream and read the byte stream out. However, how can I tell if the column that I'm reading is text or ntext, and hence, to interpret the byte stream as ASCII or Unicode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
CDynamicAccessor 类用 DBTYPE_UNKNOWN 覆盖该列的原始 DBTYPE 值。为了获得原始的DBTYPE,我们需要调用GetColumnInfo函数。如何执行此操作的一个示例是 Visual Studio 2008 示例中包含的 DynamicConsumer 示例应用程序:
替代解决方案是将 CDynamicAccessor 设置为 DBBLOBHANDLING_NOSTREAMS,这似乎会导致处理数据加载的代码更加简单(您可以在完整的 VS2008 示例代码)。
但是,我不确定为什么使用流是默认选项,以及不使用流是否有任何缺点。
The CDynamicAccessor class overwrites the original DBTYPE value of the column with DBTYPE_UNKNOWN. In order to get the original DBTYPE, we need to call the GetColumnInfo function. An example of how to do this is the DynamicConsumer sample application included in the Visual Studio 2008 samples:
The alternative solution is to set the CDynamicAccessor to DBBLOBHANDLING_NOSTREAMS, which seems to result in much less complicated code to handle data loading (you can see this in the full VS2008 sample code).
However, I'm not sure why using stream is the default option, and if there is any disadvantages with using no streams.