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

问题描述

大家好

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

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

推荐答案

 

 


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

08-22 16:53