發生場景:
1:如果資料表使用XML資料類型
2:使用ASP.net 2.0
3::使用精靈產生SqlDataSource配合DetailsView新增/更新資料庫XML資料類型
錯誤訊息:
Server Error in '/' Application.
-------------------------------------------------- ------------------------------
Operand type clash: sql_variant is incompatible with xml
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.S is incompatible with xml
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
解決辦法:
<DeleteParameters>
<asp:Parameter Name="original_ArticleID" Type="Int32" />
<asp:Parameter Name="original_Title" Type="String" />
<asp:Parameter Name="original_CategoryID" Type="Int32" />
<asp:Parameter Name="original_Contents" Type="String" />
<asp:Parameter Name="original_ArticleFrom" Type="String" />
<asp:Parameter Name="original_CreateDate" Type="DateTime" />
<asp:Parameter Name="original_keywordXML" Type="Object" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Contents" Type="String" />
<asp:Parameter Name="ArticleFrom" Type="String" />
<asp:Parameter Name="CreateDate" Type="DateTime" />
<asp:Parameter Name="keywordXML" Type="Object" />
<asp:Parameter Name="original_ArticleID" Type="Int32" />
<asp:Parameter Name="original_Title" Type="String" />
<asp:Parameter Name="original_CategoryID" Type="Int32" />
<asp:Parameter Name="original_Contents" Type="String" />
<asp:Parameter Name="original_ArticleFrom" Type="String" />
<asp:Parameter Name="original_CreateDate" Type="DateTime" />
<asp:Parameter Name="original_keywordXML" Type="Object" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Title" Type="String" />
<asp:Parameter Name="CategoryID" Type="Int32" />
<asp:Parameter Name="Contents" Type="String" />
<asp:Parameter Name="ArticleFrom" Type="String" />
<asp:Parameter Name="CreateDate" Type="DateTime" />
<asp:Parameter Name="keywordXML" Type="Object" />
</InsertParameters>
將底線部分Type="Object" -〉Type="String"