SQL字符串或二进制数据将被截断,列名称

时间:2022-01-18 15:46:00

We have simply UI application for which we use a SQL Server database. The issue is when user giving data more than the column length and hence gets an error:

我们有简单的UI应用程序,我们使用SQL Server数据库。问题是当用户提供的数据超过列长度时会出现错误:

String or binary data would be truncated

字符串或二进制数据将被截断

Is it possible to find the column causing this issue at runtime? Our application is designed in such a way that, UI label and column name is in sync. So if we are available to find column name at run time, then we can let user to correct it then and there.

是否有可能在运行时找到导致此问题的列?我们的应用程序设计为UI标签和列名称同步。因此,如果我们可以在运行时查找列名,那么我们可以让用户在那里进行更正。

Any help will be appreciated.

任何帮助将不胜感激。

1 个解决方案

#1


0  

The error message is pretty clear: the data you are trying to fit in such a field is too big for the field itself. Check your insert statement.

错误信息非常清楚:您尝试适应此类字段的数据对于字段本身来说太大了。检查插入语句。

Then look at the column definition: you have a defined length of (say) 10 or 50 characters but the data you are trying to insert is longer than that. Either increase the size of the column, or reduce the size of the data you are sending.

然后查看列定义:您有一个定义的长度(例如)10或50个字符,但您尝试插入的数据比此长。要么增加列的大小,要么减小要发送的数据的大小。

i hope its may be helps you..

我希望它可以帮助你..

#1


0  

The error message is pretty clear: the data you are trying to fit in such a field is too big for the field itself. Check your insert statement.

错误信息非常清楚:您尝试适应此类字段的数据对于字段本身来说太大了。检查插入语句。

Then look at the column definition: you have a defined length of (say) 10 or 50 characters but the data you are trying to insert is longer than that. Either increase the size of the column, or reduce the size of the data you are sending.

然后查看列定义:您有一个定义的长度(例如)10或50个字符,但您尝试插入的数据比此长。要么增加列的大小,要么减小要发送的数据的大小。

i hope its may be helps you..

我希望它可以帮助你..