无法解决这个问题....是否存在任何此类异常的解决方案...由于此异常,数据未被添加到数据库表中 [英] can't handle this....is there any solution for this kind of exception...due to this exception the data is not getting added to the database table

查看:71
本文介绍了无法解决这个问题....是否存在任何此类异常的解决方案...由于此异常,数据未被添加到数据库表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

System.Data.SqlClient.SqlException (0x80131904): String or binary data would be truncated. The statement has been terminated. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning() at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at Admin_add_del_shop.button1_Click1(Object sender, EventArgs e) in c:\Users\Sony\Documents\Visual Studio 2010\WebSites\Review_bhilai\Admin_add_del_shop.aspx.cs:line 100

推荐答案

当你遇到此错误时该字段不足以容纳您尝试存储在其中的数据。要解决此问题,您应该将字段的最大长度更改为更高的值。
You get this error when the field is not big enough to hold the data you try to store in it. To solve this, you should change the max length of the field to something higher.


检查您尝试将数据插入的数据库列。为数据定义的长度小于您尝试插入的长度。



例如,如果您尝试将值插入定义为Firstname Varchar的列( 50),并且该值的长度超过50,那么这将给出您提到的相同例外。
Check the database column you are trying to insert the data in to. The length defined for the data is less than what you are trying to insert.

For example, If you try to insert a value to a column defined as Firstname Varchar(50), and that value has a length over 50 then this will give the same exception you have mentioned.


这篇关于无法解决这个问题....是否存在任何此类异常的解决方案...由于此异常,数据未被添加到数据库表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆