我有一个SqlDataSource
和<asp:ListView>
设置处理的另一种形式的意见,具有以下文本:截断字符串数据误差(最大)字段
<asp:TextBox ID="CommentTextBox" runat="server" Text='<%# Bind("Comment") %>' Width="400px" Height="125px" TextMode="MultiLine" />
数据源具有以下InsertCommand
和asp:Parameter
设置就可以了:
InsertCommand="INSERT INTO [tblSLS_SpecComments] ([SpecID], [Author], [Comment]) VALUES (@SpecID, @Author, @Comment)"
<asp:Parameter Name="SpecID" Type="Int32" />
<asp:Parameter Name="Author" Type="String" />
<asp:Parameter Name="Comment" Type="String" />
当我尝试插入一个较长的注释(一个例子是500“F的),我得到一个错误:
String or binary data would be truncated.
The statement has been terminated.
我插入的列是数据类型nvarchar(max)
,所以它应该能够保存一本书的字符价值,这比我交付的字符要少得多。
有关发生了什么的任何线索?
是否可以超过作者列的长度? –
不应该。作者被设置为nvarchar(50),并且在后面的代码中被截断以仅作为用户名(验证过)。 – Crimius
@Crimius - 使用SQL Server Profiler来跟踪正在执行的查询。你可以看到到底发生了什么。我会认为Mush先生在这里是正确的:) – Meff