Error : String or binary data would be truncated.
The statement has been terminated. ตรง ExecuteNonQuery()sqlrent2 ค่ะ รบกวนผู้รู้ช่วยแก้ทีค่ะทำโปรเจคมะเสร็จสักทีค่ะ ขอบพระคุณมากค่ะ
Code (VB.NET)
Private Sub ToolStripButton2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButton2.Click
Dim impg As String = ""
If TextBox1.Text = "" Then
MessageBox.Show("กรุณาระบุเลขที่เอกสารด้วยค่ะ", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
generate() '---------------รันเลขที่เอกสารอัตโนมัติ
With conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = state
.Open()
End With
Dim comupdate As SqlCommand = conn.CreateCommand()
Dim tr As SqlTransaction
tr = conn.BeginTransaction()
With comupdate
.Connection = conn
.Transaction = tr
End With
Dim sqlrent1 As String = ""
Dim sqlrent2 As String = ""
sqlrent1 = " insert into ISN(ISNID, CarType, PrintDATE, CarISN)"
sqlrent1 &= "values('" & TextBox1.Text & "','" & CStr(ComboBox1.SelectedIndex) & "','" & DateTimePicker1.Text & "','" & TextBox13.Text & "')"
With comupdate
.CommandText = sqlrent1
.ExecuteNonQuery()
End With
Dim i As Integer = 0
For i = 0 To lsvCDOrDVD.Items.Count - 1
sqlrent2 = "insert into ISNDetail(ISNID, CNITEM, INV, CustomerID, FullName, Address1, Address2, Phone, Fax, BoxSmall, BoxMeddle, BoxBig)"
sqlrent2 &= "values ('" & TextBox1.Text & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(1).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(2).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(3).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(4).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(5).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(6).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(7).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(8).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(9).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(10).Text) & "',"
sqlrent2 &= "'" & CStr(lsvCDOrDVD.Items(i).SubItems(11).Text) & "')"
With comupdate
.CommandText = sqlrent2
.ExecuteNonQuery()
End With
Next
If MessageBox.Show(impg, "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
tr.Commit()
MessageBox.Show("บันทึกเรียบร้อยแล้ว", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
showISN(False)
showInvoice(False)
Bnew.Enabled = False
ToolStripButton1.Enabled = False
tsExchange.Enabled = False
ToolStripButton2.Enabled = False
ToolStripButton3.Enabled = False
tsCancel.Enabled = True
Button2.Enabled = False
ComboBox1.Enabled = True
tsAdd.Enabled = False
ClearAllDataISN()
ClearAllBinding()
Else
tr.Rollback()
End If
End Sub