Problem:
"System. Data. SqlClient. SqlException" type unprocessed exceptions occur in System. Data. dll. Other information: truncates string or binary data.
This is a problem encountered when setting the basic data of the data room charging system.
In the Code UI Layer, Try ...... Catch caught exceptions, such:
But if you haven't encountered this problem, you can't solve it simply by looking at it. So I Try ...... Comment out the Catch and find the detailed information for throwing an exception:
Solution:
First, it is "System. data. sqlClient. sqlException ", you don't need to think about it. It must be a database problem. After debugging, we found the field value basicDataBLL inserted into the database. the SetDate value is "2014/6/17 Tuesday ":
However, the data type I set for this field in the database is varchar (10), which is far less than the space occupied by "2014/6/17 Tuesday! Therefore, the capacity of the data type was decisively increased, and varchar (10) programming varchar (20) was solved.
Summary:
Another test was conducted to reduce the storage capacity of other string, text, and other types of fields in the database. This problem also occurs, and a conclusion is obtained:
The cause of this problem isThe data type of a field in the database is insufficient to store the data length of the value to be inserted into the field.When the problem occurs, add the length of the Data Type of the corresponding field.