Unhandled SqlException

Posted on 2011-05-04
Last Modified: 2012-05-11
This code has worked 100 times and suddenly I received the following message....I have no idea where it came from....

SqlException was unhandled
String or binary data would be truncated.
The statement has been terminated.

The error is happening at this code:
DA_Slip_Header.Update(DS_Slip_Header, "Slip_Info")

AND this code is in a Try/Catch - but I took it out to see exactly where the error is occuring...

There is a button click that triggers this sub...

Private Sub Save_Slip_Header_Info()

        Dim command_builder As SqlCommandBuilder
        Dim DA_Slip_Header As SqlDataAdapter
        DA_Slip_Header = New SqlDataAdapter("Select * from Slip_Info", My.Settings.IEC_DB_Connection)

        command_builder = New _

        Dim DS_Slip_Header As DataSet = New DataSet

        Dim dtaSlip_Info As New DataTable("Slip_Info")

        DA_Slip_Header.TableMappings.Add("Table", "Slip_Info")

        Dim Row_Slip_Header As DataRow = dtaSlip_Info.NewRow
        Row_Slip_Header("Slip_Number") = Me.txt_Slip_Number.Text
        Row_Slip_Header("Job_Number") = Me.txt_Job_Number.Text
        Row_Slip_Header("SWO_ID") = Me.txt_SWO_ID.Text
        Row_Slip_Header("Engineer_Last_Name") = Me.txt_Engineer.Text
        Row_Slip_Header("Contractor_Name") = Me.txt_contractor.Text
        Row_Slip_Header("Description") = Me.txt_Description.Text
        Row_Slip_Header("Slip_Date") = Me.DatePick_Slip_Date.Value.ToString
        Row_Slip_Header("Date_Added") = Date.Today.ToString
        Row_Slip_Header("Date_Changed") = Date.Today.ToString
        Row_Slip_Header("CreatedBy") = "tgeorge"
        Row_Slip_Header("Location") = Me.txt_Location.Text


        DA_Slip_Header.Update(DS_Slip_Header, "Slip_Info")

        'Clear all the textboxes

    End Sub

Open in new window

Question by:tobin46
    LVL 39

    Accepted Solution

    This error message appears when you try to insert a string with more characters than the column can maximal accommodate.

    The statement cannot be executed this way. You must either shorten the string to be isnerted to widen the column.
    LVL 29

    Assisted Solution

    by:Paul Jackson
    The error suggests that some of the data being added would be truncated when updated in the database because the size of the database column is too small.
    LVL 1

    Author Comment

    Ahhh...I think its the line:
    Row_Slip_Header("Slip_Date") = Me.DatePick_Slip_Date.Value.ToString

    I changed the length in the DB and I believe it is trying to add as date time: 5/4/2011 12:13:00AM...

    Let me address this somehow...
    LVL 1

    Author Closing Comment

    Thanks, that was it.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Join & Write a Comment

    Article by: Kraeven
    Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now