SQL Server不处理NText,Text,Xml或Image数据类型的比较
当数据绑定转发器时发生此错误: SQL Server无法处理NText,Text,Xml或Image数据类型的比较
This error occurs when data binding a repeater: SQL Server does not handle comparison of NText, Text, Xml, or Image data types
protected void Page_Load(object sender, EventArgs e)
{
topicid = Convert.ToInt32(Request.QueryString["topic".ToString()]);
if (!IsPostBack)
{
MusicForumDataContext db = new MusicForumDataContext();
var query = from p in db.posts
where p.categoryid == NAME
select p;
rptposts.DataSource = query;
rptposts.DataBind(); <---- ERROR
}
}
NTEXT,TEXT和IMAGE类型已被弃用,必须将其替换为NVARCHAR(MAX),VARCHAR(MAX)和VARBINARY(MAX)类型.新类型支持字符串运算符,包括相等性比较.
NTEXT, TEXT and IMAGE types are deprecated and must be replaced with the NVARCHAR(MAX), VARCHAR(MAX) and VARBINARY(MAX) types. The new types support string operators, including equality comparison.
XML绝不能作为字符串进行比较. XML片段可以以数千种方式编写,并且在语义上以相同的XML生成.只是想一想命名空间以及如何可以随意声明它们.
XML can never be compared as a string. XML snippets can be written in thousands of ways and result semantically in the same XML. Just think at namespaces and how they can be declared however one likes.