Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > .NET Framework > Forum > ขึ้นString or binary data would be truncated. The statement has been terminated. ช่วยหน่อยครับ



 

ขึ้นString or binary data would be truncated. The statement has been terminated. ช่วยหน่อยครับ

 



Topic : 076092



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์




มันขึ้นerrorตรงที่ผมทำตัวหนาไว้อ่าครับ ผมอยากรู้ว่ามันเกี่ยวกับดาต้าเบสหรือป่าว

Code (VB.NET)
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Imports System.Linq
Imports System.Text
Imports System.Collections.Generic
Imports System.Drawing
Imports System.Drawing.Image
Imports System.Windows.Forms
Imports System.Drawing.Printing
Imports System.Reflection
Public Class frmCustomer
    Private webcam As Webcam
    Private ClassProcessDateAGE As ProcessDate
    Public locationPhoto, locationPhotoEducation As String
    Public Conn As SqlConnection
    Public com As SqlCommand
    Public strConn As String
    Public tr As SqlTransaction
    Public sb As New StringBuilder()
    Public bs As New BindingSource()
    Public IsFind As Boolean = False
    Dim strSQL2 As String
    Dim num As Integer
    'SET MEMBER
    Public tb_Name As String = "tbCustomer"
    Public fieldId As String = "CustomerID"
    Public field1 As String = "NameCategoryRental"
    Public field2 As String = "SexName"
    Public field3 As String = "AheadName"
    Public field4 As String = "FLName"
    Public field5 As String = "CardID"
    Public field6 As String = "BirthDate"
    Public field7 As String = "Address"
    Public field8 As String = "Telephone"

    Public th As String = "ลูกค้า"
    'SET TYPE
    Public tb_NameAhead As String = "tbAheadName"
    Public fieldIdAhead As String = "AheadNameID"
    Public field1Ahead As String = "AheadName"

    Public tb_NameSex As String = "tbSex"
    Public fieldIdSex As String = "SexID"
    Public field1Sex As String = "SexName"

    Public tb_NameCategoryR As String = "tbCategoryRental"
    Public fieldIdCategoryR As String = "CategoryRentalID"
    Public field1CategoryR As String = "NameCategoryRental"
    '
    Dim da, da2, da3, da4, da5, da6, da7, da8, da9, da10, da11 As SqlDataAdapter
    Dim ds, ds2, ds3, ds4, ds5, ds6, ds7, ds8, ds9, ds10, ds11 As New DataSet() 
   Private Sub btnInsert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        ReadConnectSQLServer()
        If txtCustomerID.Text.Trim() = "" Then
            MessageBox.Show("กรุณาป้อนเลขที่" & th & "ก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtCustomerID.Focus()
            Exit Sub
        End If

        If txtFirstName.Text.Trim() = "" Then
            MessageBox.Show("กรุณาป้อนชื่อ" & th & "ก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtFirstName.Focus()

            Exit Sub
        End If

        If txtCardID.Text.Trim() = "" Then
            MessageBox.Show("กรุณาป้อนเลขบัตรประชาชน" & th & "ก่อน !!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            txtCardID.Focus()

            Exit Sub
        End If

        If MessageBox.Show("คุณต้องการเพิ่ม" & th & "ใหม่ ใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
            Dim strSQL, strSQL2, strSQL3 As String
            Dim intNumRow, intNumRow2, intNumRow3 As Integer
            strSQL = "SELECT COUNT(*) FROM " & tb_Name & "  WHERE " & fieldId & " = '" & txtCustomerID.Text & "' "
            Dim objCmd, objCmd2, objCmd3, objCmd4, objCmd5, objCmd6 As New SqlCommand
            objCmd = New SqlCommand(strSQL, Conn)
            intNumRow = objCmd.ExecuteScalar()

            strSQL2 = "SELECT COUNT(*)  FROM  " & tb_Name & "  WHERE " & field4 & " = '" & txtFirstName.Text & "' "
            objCmd2 = New SqlCommand(strSQL2, Conn)
            intNumRow2 = objCmd2.ExecuteScalar()

            strSQL3 = "SELECT COUNT(*)  FROM  " & tb_Name & "  WHERE " & field5 & " = '" & txtCardID.Text & "' "
            objCmd3 = New SqlCommand(strSQL2, Conn)
            intNumRow3 = objCmd2.ExecuteScalar()

            If intNumRow3 > 0 Then
                MessageBox.Show("เลขบัตรประชนซ้ำ!!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                Exit Sub
            End If
            If intNumRow2 > 0 Then
                MessageBox.Show("ชื่อซ้ำ!!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                Exit Sub
            End If
            If intNumRow > 0 Then
                MessageBox.Show("เลขที่ลูกค้าซ้ำ!!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                Exit Sub
            Else
                Dim com As New SqlCommand("INSERT INTO " & tb_Name & "(" & fieldId & "," & field1 & "," & field2 & "," & field3 & "," & field4 & "," & field5 & "," & field6 & "," & field7 & "," & field8 & ") VALUES('" & txtCustomerID.Text.ToString & "','" & cbCateRental.SelectedValue.ToString & "','" & cbSex.SelectedValue.ToString & "','" & cbAheadName.SelectedValue.ToString & "','" & txtFirstName.Text.ToString & "','" & txtCardID.Text.ToString & "','" & DateTimePicker1.Text.ToString & "','" & txtAddress.Text.ToString & "','" & txtTelephone.Text.ToString & "')", Conn)

                com.ExecuteReader()

                ShowData()
                Format()
                MessageBox.Show("ทำการบันทึกเรียบร้อย!!!", "ผลการตรวจสอบ", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            End If
        End If

        txtFirstName.Focus()
    End Sub


ดาต้าเบสของผมเป็นvarcharทั้งหมดอ่าครับ



Tag : .NET, Ms SQL Server 2008, Win (Windows App), VB.NET, VS 2010 (.NET 4.x)







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2012-03-25 15:24:34 By : jikaro View : 3898 Reply : 3
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ฟิวด์กับข้อมูลไม่พอดีกันครับ เช่น Varchar(100) แต่อักษรมีซะ 300






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-25 22:14:59 By : webmaster
 


 

No. 2



โพสกระทู้ ( 38 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณครับ คือ ถ้าผมพิมอักขระ 300 Varchar (300) ผมก็ต้อง 300ใช่มั้ยครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-26 21:48:21 By : jikaro
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

ประมาณนั้นครับ
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2012-03-27 06:14:04 By : webmaster
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ขึ้นString or binary data would be truncated. The statement has been terminated. ช่วยหน่อยครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 04
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่