字符串或二进制数据将被截断插入数据 [英] String or binary data would be truncated inserting data

查看:84
本文介绍了字符串或二进制数据将被截断插入数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

插入数据时出现问题.错误显示字符串或二进制数据将被截断.那是什么意思?

I have problem when i inserted data. the error show String or binary data would be truncated. What is meaning of that??

这是我的代码:


 Try
            SQLCONNECTIONS.connect()
            Dim sqlcmd As New SqlCommand
            Dim applybefor As String
            If RadioButton1.Checked = True Then
                applybefor = "Yes"
            Else
                applybefor = "No"
            End If
            Dim torwithoutso As String
            If rbtorwithoutSO.Checked = True Then
                torwithoutso = ("Transcript of Records without Special Order" + "-" + TextBox5.Text)
            Else
                torwithoutso = "Aw"
            End If
            Dim torwithso As String
            If rbwithso.Checked = True Then
                torwithso = ("Transcript of Records with Special Order" + "-" + txtdateissued.Text)
            Else
                torwithso = "Aw"

            End If
            Dim status1 As String
            status1 = "Auditing"

            With sqlcmd.Parameters
                .Add(New SqlParameter("@StudentNo", lblstudentno.Text))
                .Add(New SqlParameter("@SONo", lblsono.Text))
                .Add(New SqlParameter("@DateApplied", txtdateissued.Text))
                .Add(New SqlParameter("@LastName", lbllastname.Text))
                .Add(New SqlParameter("@FirstName", lblfirstname.Text))
                .Add(New SqlParameter("@MiddleName", lblmiddlename.Text))
                .Add(New SqlParameter("@Course", lblcourse.Text))
                .Add(New SqlParameter("@Major", lblmajor.Text))
                .Add(New SqlParameter("@Address", txtaddress.Text))
                .Add(New SqlParameter("@ContactNo", txtcontact.Text))
                .Add(New SqlParameter("@HSGraduated", txthsgrad.Text))
                .Add(New SqlParameter("@YearGraduated", MaskedTextBox1.Text))
                .Add(New SqlParameter("@AppliedTORBefore", applybefor))
                .Add(New SqlParameter("@TORWithSO", torwithso))
                .Add(New SqlParameter("@TORWithoutSO", torwithoutso))
                .Add(New SqlParameter("@TORPayment", ComboBox1.SelectedItem))
                .Add(New SqlParameter("@AlumniFee", ComboBox2.SelectedItem))
                .Add(New SqlParameter("@DocStamps", ComboBox3.SelectedItem))
                .Add(New SqlParameter("@Library", ComboBox4.SelectedItem))
                .Add(New SqlParameter("@TreasureOffice", ComboBox5.SelectedItem))
                .Add(New SqlParameter("@SAO", ComboBox6.SelectedItem))
                .Add(New SqlParameter("@Status", status1))
                .Add(New SqlParameter("@Notes", txtnotes.Text))
            End With
            sqlstr = "insert into TblTorGrad (StudentNo, SONo, DateApplied, LastName, FirstName, MiddleName, Course, Major, Address, ContactNo, HSGraduated, YearGraduated, AppliedTORBefore, TORWithSO, TORWithoutSO, TORPayment, AlumniFee, DocStamps, Library, TreasureOffice, SAO, Status, Notes)" & _
                "values(@StudentNo,@SONo,@DateApplied,@LastName,@FirstName,@MiddleName,@Course,@Major,@Address,@ContactNo,@HSGraduated,@YearGraduated,@AppliedTORBefore,@TORWithSO,@TORWithoutSO,@TORPayment,@AlumniFee,@DocStamps,@Library,@TreasureOffice,@SAO,@Status,@Notes)"
            sqlcmd.CommandText = sqlstr
            sqlcmd.Connection = conn
            sqlcmd.ExecuteNonQuery()
            MsgBox("Save Success", MsgBoxStyle.Information)
            txtaddress.Clear()
            txtcontact.Clear()
            txthsgrad.Clear()
            txtdateissued.Clear()
            txtnotes.Clear()
            TextBox5.Clear()
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

推荐答案

SQL表中的字段可能小于您所希望且不能包含的值,因此该值将被截断.

Probably a field in your SQL table is smaller than the value you suply and cannot contain that so it will be truncated.

 

 


这篇关于字符串或二进制数据将被截断插入数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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