ADO不了解本机驱动程序公开的XML sql Server数据类型:
field: ADOField; field := recordset.Fields.Items["SomeXmlColumn"];
尝试访问field.Value会抛出EOleException:
>来源:Microsoft Cursor Engine
> ErrorCode:0x80040E21(E_ITF_0E21)
>消息:多步操作生成错误.检查每个状态值
本机客户端驱动程序(例如sqlNCLI,sqlNCLI11)将ADO的Xml数据类型呈现为
field.Type_ = 141 //???
旧版sqlOLEDB驱动程序将ADO的Xml数据类型显示为adLongVarWChar,即unicode字符串:
field.Type_ = 203 //adLongVarWChar
字段中包含的VARIANT值.值是WideString
(technically known as a BSTR
):
TVarData(field.Value).vtype = 8 //VT_BSTR
在我看来,这是ADO(Windows 7 SP1)中的一个错误,而不是我可以解决的问题.
我该如何解决?
奖金阅读
解决方法
To enable ADO to use new features of recent versions of sql Server,
some enhancements have been made to the sql Server Native Client OLE
DB provider which extends the core features of OLE DB. These
enhancements allow ADO applications to use newer sql Server features
and to consume two data types introduced in sql Server 2005: xml and
udt. These enhancements also exploit enhancements to the varchar,
nvarchar,and varbinary data types. sql Server Native Client adds the
SSPROP_INIT_DATATYPECOMPATIBILITY initialization property to the
DBPROPSET_sqlSERVERDBINIT property set for use by ADO applications so
that the new data types are exposed in a way compatible with ADO. In
addition,the sql Server Native Client OLE DB provider also defines a
new connection string keyword named DataTypeCompatibility that is set
in the connection string.
因此,要在Native Client中启用新的sql Server功能,您需要在连接字符串中添加以下关键字:
Provider=sqlNCLI11 DataTypeCompatibility=80
Specifies the mode of data type handling to use. Recognized values are “0” for provider data types and “80” for sql Server 2000 data types.