Link to home
Start Free TrialLog in
Avatar of tobin46
tobin46

asked on

Unhandled SqlException

This code has worked 100 times and suddenly I received the following message....I have no idea where it came from....

Error:
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 _
        SqlCommandBuilder(DA_Slip_Header)

        Dim DS_Slip_Header As DataSet = New DataSet

        Dim dtaSlip_Info As New DataTable("Slip_Info")
        DS_Slip_Header.Tables.Add(dtaSlip_Info)

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

        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

        dtaSlip_Info.Rows.Add(Row_Slip_Header)

        DA_Slip_Header.Update(DS_Slip_Header, "Slip_Info")

        'Clear all the textboxes
        Me.Clear_Textboxes()


    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tobin46
tobin46

ASKER

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...
Avatar of tobin46

ASKER

Thanks, that was it.