|
 |
|
VB.net 2008 ขึ้น error แบบนี้ครับ ไม่รู้จะแก้ยังไงดีครับ |
|
 |
|
|
 |
 |
|

พอดี ผมเพิ่งจะเริ่มหัดเขียนโปรแกรมน่ะครับ มือใหม่ ไม่มีประสบการณ์เลย เคยแต่ซื้อหนังสือมาดู พอดี vb.net มันติด error ขึ้นมาฟ้องตามภาพน่ะครับ โค๊ดเกี่ยวข้องจะเป็นแบบนี้ ไม่ทราบว่า ผมใส่เครื่องหมายผิดตรงไหนเหรอครับ กรุณาช่วยชี้แน่ะด้วยครับ ขอบคุณมากครับ
Code (VB.NET)
Private Sub cmdClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdClear.Click
lsvInstallList.Items.Clear()
txtNumber.Text = "1"
txtID_P.Focus()
End Sub
Private Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
If dtpTimeInstall.Value = Today Then
MessageBox.Show("กรุณาตรวจสอบวันที่ติดตั้งให้ถูกต้องก่อน !!!", "ตรวจสอบวันที่ติดตั้ง", MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Sub
End If
If txtID_C.Text = "" Then
MessageBox.Show("กรุณาป้อนรหัสลูกค้า", "ข้อผิดพลาด", MessageBoxButtons.OK, MessageBoxIcon.Error)
txtID_C.Focus()
Exit Sub
End If
With Conn
If .State = ConnectionState.Open Then .Close()
.ConnectionString = strConn
.Open()
End With
Dim sqlInstall As String = ""
Dim comInstall As OleDbCommand = Conn.CreateCommand()
With comInstall
.Connection = Conn
End With
sqlInstall = "INSERT INTO t_Install(ID_I,Docno,Type_I,EquipID,EquipName,Model,Color,SerialNumber,"
sqlInstall &= " Date_I,Date_X,Date_C,Date_F,Period_I,Location_I,Name_C,Engineer,Comment)"
sqlInstall &= " VALUES('" & LastID_I & "',"
sqlInstall &= "'" & txtDocno.Text & "',"
sqlInstall &= "'" & CStr(cboTypeInstall.SelectedValue) & "',"
sqlInstall &= "'" & txtMainID.Text & "',"
sqlInstall &= "'" & txtMainName.Text & "',"
sqlInstall &= "'" & txtMainModel.Text & "',"
sqlInstall &= "'" & CStr(cboColor.SelectedValue) & "',"
sqlInstall &= "'" & txtSerialNumber.Text & "',"
sqlInstall &= "'" & txtRoom.Text & "',"
sqlInstall &= "'" & txtPeriod.Text & "',"
sqlInstall &= "'" & dtpTimeInstall.Value = Date.Today & "',"
sqlInstall &= "'" & dtpExammine.Value = Date.Today & "',"
sqlInstall &= "'" & dtpCompanyExpire.Value = Date.Today & "',"
sqlInstall &= "'" & dtpCompanyExpire.Value = Date.Today & "',"
sqlInstall &= "'" & dtpSupplierExpire.Value = Date.Today & "',"
sqlInstall &= "'" & txtEngineer.Text & "'"
sqlInstall &= "'" & txtComment.Text & "'"
With comInstall
.CommandType = CommandType.Text
.CommandText = sqlInstall
.Connection = Conn
.ExecuteNonQuery()
End With
Dim i As Integer = 0
Dim sqlInDetail As String = ""
For i = 0 To lsvInstallList.Items.Count - 1
sqlInDetail = "INSERT INTO t_InstallDetail (ID_I,ID_P,Name_P,Model_P,SerialNumber_P,"
sqlInDetail &= " Number_I,Comment)"
sqlInDetail &= " VALUES ('" & LastID_I & "',"
sqlInDetail &= "'" & CStr(lsvInstallList.Items(i).SubItems(0).Text) & "',"
sqlInDetail &= "'" & CStr(lsvInstallList.Items(i).SubItems(2).Text) & "',"
sqlInDetail &= "'" & CStr(lsvInstallList.Items(i).SubItems(3).Text) & "',"
sqlInDetail &= "'" & CStr(lsvInstallList.Items(i).SubItems(4).Text) & "',"
sqlInDetail &= "'" & CStr(lsvInstallList.Items(i).SubItems(5).Text) & "',"
sqlInDetail &= "'" & CStr(lsvInstallList.Items(i).SubItems(6).Text) & "',"
With comInstall
.CommandType = CommandType.Text
.CommandText = sqlInDetail
.Connection = Conn
.ExecuteNonQuery()
End With
Next
If MessageBox.Show("ท่านต้องการบันทึกข้อมูลการติดตั้งใช่หรือไม่?", "คำยืนยัน", MessageBoxButtons.YesNo, MessageBoxIcon.Information) = DialogResult.Yes Then
MessageBox.Show("บันทึกรายการติดตั้งเรียบร้อยแล้ว!!!", "ผลการทำงาน", MessageBoxButtons.OK, MessageBoxIcon.Information)
lsvInstallList.Items.Clear()
Call ClearCustomerData()
Call ClearAllInstallData()
totalNet.Text = "0"
cmdSave.Enabled = False
txtDocno.Focus()
End If
End Sub
Tag : .NET, VB.NET

|
|
 |
 |
 |
 |
Date :
2012-11-06 09:56:58 |
By :
peepong |
View :
1308 |
Reply :
8 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
sqlInstall ค่าผิดแน่นอนครับ ที่เห็นก็มี หลัง txtEngineer.Text ไม่มี "," และก็ไม่มีวงเล็บปิดในส่วนของ Values ด้วย ผิดที่ SQL Command นี้แหละครับ
|
 |
 |
 |
 |
Date :
2012-11-06 11:00:25 |
By :
??? |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
'Dim comInstall As OleDbCommand = Conn.CreateCommand()
Dim comInstall As New OleDbCommand
'With comInstall
'.Connection = Conn
'End With
น่าจะใด้นะ
|
 |
 |
 |
 |
Date :
2012-11-06 11:06:03 |
By :
44 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
sqlInstall &= "'" & txtEngineer.Text & "'"
sqlInstall &= "'" & txtComment.Text & "'"
ผมว่าน่าจะผิดที่สองบรรทัดนี้นะ
่น่าจะเป็น
sqlInstall &= "'" & txtEngineer.Text & "',"
sqlInstall &= "'" & txtComment.Text & "')"
msn มาคุยกันนะ [email protected]
|
 |
 |
 |
 |
Date :
2012-11-06 12:57:25 |
By :
ดำ ชลบุรี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณทุกคำตอบ ที่กรุณาชี้แน่ะมาน่ะครับ ผมจะลองไปทำดูครับ ได้ผลยังไงจะมาบอกว่าครับ
|
 |
 |
 |
 |
Date :
2012-11-07 00:49:15 |
By :
pee |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมได้แก้บรรทัดตามที่ท่าน ดำ ชลบุรี แน่ะนำแล้ว ก็ยังขึ้นerror เหมือนเดิมครับ ไม่รู้จะแก้ไงดีต่อครับ ขอรบกวนอีกครั้งน่ะครับ ขอบคุณครับ 

|
 |
 |
 |
 |
Date :
2012-11-07 09:24:00 |
By :
peepong |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันก็ยังขึ้นมาเหมือนเดิมครับ ตามรูป

ขอขอบคุณผู้ที่ชี้แน่ะทั้ง 3 ด้วยครับ
1. คุณ ???
2. คุณ 44
3. คุณ ดำ ชลบุรี
|
 |
 |
 |
 |
Date :
2012-11-07 09:34:13 |
By :
peepong |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Debug เอาค่าตัวแปร sqlinstall มาให้ดูหน่อยครับ
|
 |
 |
 |
 |
Date :
2012-11-07 09:36:06 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เอางี้
ผมใจร้อน
คุณลง teavviewer 7 เดียวผมรีโมตไปดูให้
ลงเสร้จส่ง id พาสเวิด เข้าเมลผมเลย
หรือไม่ก็เอ็มมาบอก
[email protected]
|
 |
 |
 |
 |
Date :
2012-11-07 09:58:03 |
By :
dum_chonburi |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|