 |
|
กดปุ่ม Update แล้ว มันบอกว่าบันทึกเรียบร้อย แต่ไม่มีการเปลี่ยนแปลงใดๆ |
|
 |
|
|
 |
 |
|
-ขออนุญาตมาตั้งหัวข้อใหม่เพราะตอนนี้ปัญหามันเปลี่ยนไป
-ในUpdate ได้เปลี่ยนจาก Where His_product เป็น Where ID ซึ่งในฐานข้อมูลเป็นAutonumberและเป็นคีย์หลัก
อันนี้เป็นโค้ดของปุ่มUpdate
Code (VB.NET)
Try
Dim cmd As New OleDbCommand
If Not con.State = ConnectionState.Open Then
'open connection
con.Open()
End If
cmd.Connection = con
'check whether add new or update
If Me.semat.Tag & "" = "" Then
'add new
'add data to table
cmd.CommandText = " INSERT INTO Tb_History(His_product, His_number, His_student, His_teacher, His_date, His_time)" & _
" VALUES ('" & Me.semat.Text & "'," & Me.txtnum.Text & ",'" & _
Me.txtna1.Text & "','" & Me.txtna2.Text & "','" & Me.txtdate.Text & "','" & _
Me.txttime.Text & "')"
cmd.ExecuteNonQuery()
Else
'update data in table
Dim intsi As Integer
cmd.CommandText = " Update Tb_History SET " & _
" His_product= '" & Me.semat.Text & "' " & _
" ,His_number=" & Me.txtnum.Text & _
" ,His_student= '" & Me.txtna1.Text & "' " & _
" ,His_teacher= '" & Me.txtna2.Text & "' " & _
" ,His_date= '" & Me.txtdate.Text & "' " & _
" ,His_time= '" & Me.txttime.Text & "' " & _
" WHERE ID= " & intsi & ""
cmd.ExecuteNonQuery() 'ใช้กับ Insert update delete
End If
'refresh data in list
RefreshData()
'close connection
con.Close()
MessageBox.Show("บันทึกลงตารางเรียบร้อยแล้ว")
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
End Try
และอันนี้เป็นโค้ดของปุ่มEdit
Code (VB.NET)
If MessageBox.Show("คุณต้องการแก้ไขข้อมูลบรรทัดนั้ใช่หรือไม่ ?", "ยืนยันการแก้ไขข้อมูล", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
If Me.DataGridView1.Rows.Count > 0 Then
If Me.DataGridView1.SelectedRows.Count > 0 Then
Dim intsi As Integer = Me.DataGridView1.SelectedRows(0).Cells("ID").Value
Dim intsis As String = Me.DataGridView1.SelectedRows(0).Cells("His_product").Value
'open connnection
If Not con.State = ConnectionState.Open Then
con.Open()
End If
'get data into datatable
Dim da As New OleDbDataAdapter("SELECT * FROM Tb_History " & _
" WHERE ID = " & intsi & "", con)
Dim dt As New DataTable()
da.Fill(dt)
Me.semat.Text = dt.Rows(0).Item("His_product")
Me.txtnum.Text = dt.Rows(0).Item("His_number")
Me.txtna1.Text = dt.Rows(0).Item("His_student")
Me.txtna2.Text = dt.Rows(0).Item("His_teacher")
Me.txtdate.Text = dt.Rows(0).Item("His_date")
Me.txttime.Text = dt.Rows(0).Item("His_time")
'hide the Hisproduct to be edited in TAG of semat.text in case His_product changed
Me.semat.Tag = intsi 'หรือป่าว
'change button add to อัพเดทข้อมูล
Me.add.Text = "อัพเดทข้อมูล"
Me.RefreshData()
'disable button edit
Me.edit.Enabled = True
'close connection
con.Close()
End If
End If
End If
End Sub
และรูปนี้มันพอจะเป็นประโยชน์มั้ย

Tag : .NET, Ms Access, VS 2012 (.NET 4.x)
|
|
 |
 |
 |
 |
Date :
2015-09-29 11:43:52 |
By :
peemes101 |
View :
2392 |
Reply :
22 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
cmd.CommandType = cmd.CommandType .Text
|
 |
 |
 |
 |
Date :
2015-09-30 15:37:07 |
By :
Balll2iFFer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันขึ้นแบบนี้

ปล. ID ซึ่งในฐานข้อมูลเป็นAutonumber
|
 |
 |
 |
 |
Date :
2015-09-30 17:05:37 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองทำการ D-bug ดูก่อนครับ F11 อ่ะ กดไปเรื่อยๆ
|
 |
 |
 |
 |
Date :
2015-10-01 09:33:22 |
By :
Balll2iFFer |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้าโปรแกรมไม่แจ้ง error
ก็น่าจะผิดที่คำสั่ง sql ตรง where น่ะครับ
ลอง Debug ดูคำสั่ง sql หน่อยครับ
ว่าสุดท้ายแล้วคำสั่งที่ได้มีอะไรบ้าง
|
 |
 |
 |
 |
Date :
2015-10-01 09:55:26 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กดF11แล้วขึ้นดังรูป

แต่พอเปลี่ยนเป็น
Code (VB.NET)
" Where ID =" & srtid.ToString("ID") & " "
่
มันกลับแก้ได้ แต่ มันไปแก้ทุกแถวเลย
และ
พอเปลี่ยนเป็น " Where His_product = '" & Me.semat.Tag & "' " มันอัพเดทได้ ในกรณีที่productนั้นมีแค่แถวเดียว ซึ่งถ้ามีproductนั้นหลายแถวมันจะไปอัพเดทด้วย
|
ประวัติการแก้ไข 2015-10-01 22:24:22
 |
 |
 |
 |
Date :
2015-10-01 17:51:02 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เห็นว่าคุณNewbieXYZโพส แต่ทำไมไม่มี
แก้ไม่ได้สักที ช่วยด้วย
|
ประวัติการแก้ไข 2015-10-02 17:21:12
 |
 |
 |
 |
Date :
2015-10-02 17:16:50 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
srtid.ToString("ID")
ลองแก้เป็น
Convert.ToString(srtid) ดูครับ
|
 |
 |
 |
 |
Date :
2015-10-02 18:20:55 |
By :
NewbiePHP |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
โดยกดอัพเดทได้และบอกว่าบันทึกเรียบร้อย แต่ไม่มีอะไรเปลี่ยนแปลงครับ
และ
ทำไมพอกดอัพเดทเสร็จ แล้วจะบันทึกproductใหม่ มันกลับอัพเดทแทน
ได้ลองเปลี่ยนโน้นเปลี่ยนนี่ดังนี้
1. เปลี่ยนเป็น Where His_product ในupdate และไปเปลี่ยนที่ปุ่มแก้ไข(edit)ด้วย และได้เพิ่มนี้
" SET ID=" & srtid & " " & _
ไปในปุ่มupdate
Code (VB.NET)
Dim srtid As Integer
cmd.CommandText = "Update Tb_History " & _
" SET ID =" & srtid & "" & _
" ,His_product= '" & Me.semat.Text & "' " & _
" ,His_number=" & Me.txtnum.Text & _
" ,His_student= '" & Me.txtna1.Text & "' " & _
" ,His_teacher= '" & Me.txtna2.Text & "' " & _
" ,His_date= '" & Me.txtdate.Text & "' " & _
" ,His_time= '" & Me.txttime.Text & "' " & _
" Where His_product = '" & Me.semat.Text & "' "
1.1มันให้IDแถวแรกกลายเป็น0 ซึ่งเปลียนแค่แถวแรกและจำนวนเท่านั้น
2.พอเปลี่ยนเป็น
" Where ID = " & srtid & " "
ในupdate และไปเปลี่ยนที่ปุ่มแก้ไข(edit)ด้วย
2.1 ID แถวแรกก็ยังเป็น0อยู่และมันอัพเดทแต่แถวแรกสุด ที่ID เป็น 0
ไม่ว่าจะกดแก้แถวไหน มันก็จะไปอัพเดทที่แถวแรกสุด
หรือเป็นที่ลูกศรใน datagridview เพราะเมื่อเลือกแถวที่จะแก้ไขแล้ว ลูกศรมันกลับไปอยู่ตรงกับแถวแรกไม่ตรงกับแถวที่เลือก
ดังรูป

2.2หลังจากลบแถวIDที่เป็น0 แล้วมาแก้ไขและกดปุ่มอัพเดทก็ไม่มีอะไรเปลี่ยนแปลงเหมือนเดิม
3.โค้ดล่าสุด
ปุ่มอัพเดท
Code (VB.NET)
Dim cmd As New OleDbCommand
If Not con.State = ConnectionState.Open Then
'open connection
con.Open()
End If
cmd.Connection = con
'check whether add new or update
If Me.semat.Tag & "" = "" Then
'add new
'add data to table
cmd.CommandText = " INSERT INTO Tb_History(His_product, His_number, His_student, His_teacher, His_date, His_time)" & _
" VALUES ('" & Me.semat.Text & "'," & Me.txtnum.Text & ",'" & _
Me.txtna1.Text & "','" & Me.txtna2.Text & "','" & Me.txtdate.Text & "','" & _
Me.txttime.Text & "')"
cmd.ExecuteNonQuery()
Else
'update data in table
Dim srtid As Integer
cmd.CommandText = "Update Tb_History " & _
" SET ID =" & srtid & "" & _
" ,His_product= '" & Me.semat.Text & "' " & _
" ,His_number=" & Me.txtnum.Text & _
" ,His_student= '" & Me.txtna1.Text & "' " & _
" ,His_teacher= '" & Me.txtna2.Text & "' " & _
" ,His_date= '" & Me.txtdate.Text & "' " & _
" ,His_time= '" & Me.txttime.Text & "' " & _
" Where ID = " & srtid & " "
cmd.ExecuteNonQuery() 'ใช้กับ Insert update delete
End If
'refresh data in list
RefreshData()
'close connection
con.Close()
'clear form เพิ่มมา
Me.cancel.PerformClick()
MessageBox.Show("บันทึกลงตารางเรียบร้อยแล้ว")
ปุ่มแก้ไข
Code (VB.NET)
If MessageBox.Show("คุณต้องการแก้ไขข้อมูลบรรทัดนั้ใช่หรือไม่ ?", "ยืนยันการแก้ไขข้อมูล", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) = Windows.Forms.DialogResult.Yes Then
If Me.DataGridView1.Rows.Count > 0 Then
If Me.DataGridView1.SelectedRows.Count > 0 Then
Dim intsi As Integer = Me.DataGridView1.SelectedRows(0).Cells("ID").Value
'open connnection
If Not con.State = ConnectionState.Open Then
con.Open()
End If
'get data into datatable
Dim strSQL As String = "SELECT * FROM Tb_History " & _
" WHERE ID = " & intsi & " "
Dim da As New OleDbDataAdapter(strSQL, con)
Dim dt As New DataTable()
da.Fill(dt)
Me.semat.Text = dt.Rows(0)("His_product")
Me.txtnum.Text = dt.Rows(0)("His_number")
Me.txtna1.Text = dt.Rows(0)("His_student")
Me.txtna2.Text = dt.Rows(0)("His_teacher")
Me.txtdate.Text = dt.Rows(0)("His_date")
Me.txttime.Text = dt.Rows(0)("His_time")
'hide the Hisproduct to be edited in TAG of semat.text in case His_product changed
'ถ้าเปลี่ยนเป็นstr มันจะกลายเป็นเพิ่มแถวใหม่พอกดอัพเดท และเอาออกก็เปลี่ยนการเพิ่มแถว
Me.semat.Tag = intsi
'change button add to อัพเดทข้อมูล
Me.add.Text = "อัพเดทข้อมูล"
Me.RefreshData()
'disable button edit
Me.edit.Enabled = False
'close connection
con.Close()
End If
End If
End If
|
ประวัติการแก้ไข 2015-10-03 00:15:25 2015-10-03 02:37:28 2015-10-03 03:20:11
 |
 |
 |
 |
Date :
2015-10-02 21:37:38 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขออนุญาติถามตรง ๆ น่ะครับ
ว่าคุณ PM debug โปรแกรมเป็นไหมครับ
ผมสังเกตุว่ามักจะส่งมาแต่ code
ถ้ายังไงลองดูเว็บนี้เบื้องต้นก่อนน่ะครับ
http://pstudiodev.blogspot.com/2012/04/visual-studio-2010.html
หากทำเป็นอยู่แล้วต้องขออภัยด้วยน่ะครับ
จาก code ข้างบน
Dim srtid As Integer
cmd.CommandText = "Update Tb_History " & _
" SET ID =" & srtid & "" & _
" ,His_product= '" & Me.semat.Text & "' " & _
" ,His_number=" & Me.txtnum.Text & _
" ,His_student= '" & Me.txtna1.Text & "' " & _
" ,His_teacher= '" & Me.txtna2.Text & "' " & _
" ,His_date= '" & Me.txtdate.Text & "' " & _
" ,His_time= '" & Me.txttime.Text & "' " & _
" Where ID = " & srtid & " "
จะเห็นได้ว่ามีการใช้ srtid ในคำสั่งตรง set กับตรง where
แต่ตัวแปร srtid มันยังไม่ได้รับค่าอะไรมาเลย
ถ้าจะลอง debug ดูแบบง่าย ๆ ก็ใช้คำสั่ง msgbox ก็ได้ครับ
เช่น
Dim srtid As Integer
cmd.CommandText = "Update Tb_History " & _
" SET ID =" & srtid & "" & _
" ,His_product= '" & Me.semat.Text & "' " & _
" ,His_number=" & Me.txtnum.Text & _
" ,His_student= '" & Me.txtna1.Text & "' " & _
" ,His_teacher= '" & Me.txtna2.Text & "' " & _
" ,His_date= '" & Me.txtdate.Text & "' " & _
" ,His_time= '" & Me.txttime.Text & "' " & _
" Where ID = " & srtid & " "
msgbox(cmd.CommandText)
หรือถ้า debug ได้
เราก็สามารถ copy คำสั่ง sql
ไปลอง execute บน database ได้เลย
มันจะทำให้เรารู้ว่าคำสั่งที่ทำมามันมีปัญหาอะไรหรือปล่าว
|
 |
 |
 |
 |
Date :
2015-10-03 08:17:31 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เป็นครับ
ลองทำแล้วมันรูปดังรูป

โดยที่ตรง set กับตรง where มัน=0
แต่พอกดอัพเดทแล้วไม่มีอะไีรเปลี่ยนแปลง
ดังนั้นควรแก้อย่างไร
ซึ่งถ้ามันเป็น where his_product จะขึ้นดังรูป

โดยจะอัพเดทได้ ถ้ามีproductแค่แถวเดียว ซึ่งมันเป็นไปไม่ได้
แต่ถ้ามีproductนั้นอยู่ในแถวอื่นด้วย มันจะไปแก้ให้ด้วย
|
ประวัติการแก้ไข 2015-10-03 18:10:30 2015-10-03 18:11:42 2015-10-03 18:57:54
 |
 |
 |
 |
Date :
2015-10-03 16:26:04 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
@PM จาก #NO8 และ #NO10
ผมสรุปสาเหตุให้คุณฟังชัดชัด "การออกแบบหน้าจอ (Input/Output) ได้ไม่ดีนัก" ผลที่ตามมาก็คือ
ทำให้คุณหรือโปรแกรมเมอร์ชั่วโมงบินต่ำ เขียนโปรแกรมยากลำบากมากกว่าเดิม
...
...
...
...
...
...
ปล. ผมสรุปสาเหตุ 2 บรรทัดด้านบนให้คุณอ่าน ด้วยแรงบันดาลใจจากกระทู้นี้ครับ
https://www.thaicreate.com/dotnet/forum/075585.html
|
 |
 |
 |
 |
Date :
2015-10-03 18:30:02 |
By :
หน้าฮี |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แต่มีปัญหาอีกตรงที่
1. อยากให้textboxที่เป็นของID โชว์เฉพาะ ตอนกดปุ่มแก้ไข และหลังจากกดปุ่มอัพเดท ก็ให้ปิดเหมือนเดิม
2.พอรันใหม่ แล้วกดปุ่มแก้ไข อัพเดท เสร็จ
2.1แล้วกรอกข้อมูลใหม่หมดเพื่อบันทึกข้อมูลเป็นแถวใหม่ มัน
errorว่า "Syntax error in UPDATE statement."
ที่cmd.ExecuteNonQuery()
ดังรูป

|
 |
 |
 |
 |
Date :
2015-10-07 06:33:57 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เห็นเอาปุ่ม Autos กับ Locals โผล่มาแล้ว
ลองกด Break ที่บรรทัดที่ Error ดูครับ
พอโปรแกรมมัน Break ที่ตำแหน่งนั้นแล้ว
เราสามารถเข้าไปดูค่าต่าง ๆ ของตัวแปรได้
และสามารถ copy คำสั่ง sql ออกมาได้ด้วยครับ
1. อยากให้textboxที่เป็นของID โชว์เฉพาะ ตอนกดปุ่มแก้ไข และหลังจากกดปุ่มอัพเดท ก็ให้ปิดเหมือนเดิม
>>> อันนี้เป็นเรื่องของโปรแกรมแล้วล่ะครับ
คำสั่งก็ประมาณนี้ครับ
เมื่อกดปุ่ม Edit
ก็สั่ง TextBox.Visible= True
หลังจาก Update เสร็จแล้วก็ TextBox.Visible = False
2.พอรันใหม่ แล้วกดปุ่มแก้ไข อัพเดท เสร็จ
2.1แล้วกรอกข้อมูลใหม่หมดเพื่อบันทึกข้อมูลเป็นแถวใหม่ มัน
>>> ถ้าเป็นการกรอกข้อมูลใหม่ทำไมเข้า Update ล่ะครับ
มันตัดสินใจยังไงว่าควรจะ Insert หรือ Update ครับ
|
 |
 |
 |
 |
Date :
2015-10-07 08:45:14 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1.ที่คุณบอกโอเคแล้ว
แต่ตอนรันอยากให้มันปิดไว้จะเปิดก็ต่อเมื่อกดปุ่มแก้ไข
โดยใช้นี้เป็นค่าเริ่มต้น
Code (VB.NET)
Private Sub InitialControl()
txtidauto.Enabled = False
Label9.Enabled = False
End Sub
แต่มันไม่เห็นปิดไว้เลย ตอนรันอ่ะ
เนื่องจากtextboxของID มันอยู่ในGroupboxหรือป่าว
2.ใช่ มันควรจะเป็น insert แต่ไม่รุทำไมเข้าupdate?
เนื่องจากinsertและupdateอยู่ในปุ่มเดียวกันหรือป่าว
อันนี้เป็นโค้ดทั้งหมดของปุ่ม
Code (VB.NET)
Dim cmd As New OleDbCommand
If Not con.State = ConnectionState.Open Then
'open connection
con.Open()
End If
cmd.Connection = con
'check whether add new or update
If Me.semat.Tag & "" = "" Then
'add new
'add data to table
cmd.CommandText = " INSERT INTO Tb_History(His_product, His_number, His_student, His_teacher, His_date, His_time)" & _
" VALUES ('" & Me.semat.Text & "'," & Me.txtnum.Text & ",'" & _
Me.txtna1.Text & "','" & Me.txtna2.Text & "','" & Me.txtdate.Text & "','" & _
Me.txttime.Text & "')"
cmd.ExecuteNonQuery()
MessageBox.Show("บันทึกลงตารางเรียบร้อยแล้ว")
Else
'update data in table
cmd.CommandText = "UPDATE Tb_History " & _
"SET ID =" & Me.txtidauto.Text & "" & _
" ,His_product= '" & Me.semat.Text & "'" & _
" ,His_number=" & Me.txtnum.Text & "" & _
" ,His_student= '" & Me.txtna1.Text & "'" & _
" ,His_teacher= '" & Me.txtna2.Text & "'" & _
" ,His_date= '" & Me.txtdate.Text & "'" & _
" ,His_time= '" & Me.txttime.Text & "'" & _
" WHERE ID=" & Me.txtidauto.Text & ""
cmd.ExecuteNonQuery() 'ใช้กับ Insert update delete
MessageBox.Show("อัพเดทลงตารางเรียบร้อยแล้ว")
txtidauto.Enabled = False
Label9.Enabled = False
End If
'refresh data in list
RefreshData()
'close connection
con.Close()
Me.cancel.PerformClick()
|
 |
 |
 |
 |
Date :
2015-10-07 17:36:44 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1. ลองย้ายคำสั่งในใน event Form_Load ดูครับ
หรือไม่ก็ตั้งเป็น false ตั้งแต่หน้า design เลยก้ได้ครับ
2. มันตัดสินกันที่บรรทัดนี้
If Me.semat.Tag & "" = "" Then
ลองสั่ง
Msgbox(Me.semat.Tag) ก่อนดูครับ
อาจเป็นไปได้ว่า หลังจาก Update แล้วลืมเคลียร์ค่าเดิมออก
|
 |
 |
 |
 |
Date :
2015-10-08 07:49:20 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
1.ได้แล้วโดยเอาไปใส่ในForm_Load
2.หลังจากupdateแล้วมาinsert พอกดบันทึก แล้วขึ้นpopupว่า อัพเดทเรียบร้อยแล้ว และมาขึ้นpopupที่เป็นเลขIDของแถวที่เพิ่งupdateไป(จากโค้ดMsgbox(Me.semat.Tag)
แล้วerrorดังรูป

|
ประวัติการแก้ไข 2015-10-08 16:51:37
 |
 |
 |
 |
Date :
2015-10-08 16:47:49 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ถ้ายังใช้
Code (VB.NET)
"UPDATE Tb_History " & _
"SET ID =" & Me.txtidauto.Text & "" & _
" ,His_product= '" & Me.semat.Text & "'" & _
" ,His_number=" & Me.txtnum.Text & "" & _
" ,His_student= '" & Me.txtna1.Text & "'" & _
" ,His_teacher= '" & Me.txtna2.Text & "'" & _
" ,His_date= '" & Me.txtdate.Text & "'" & _
" ,His_time= '" & Me.txttime.Text & "'" & _
" WHERE ID=" & Me.txtidauto.Text & ""
ยังไงก็ Error ครับ
https://www.thaicreate.com/tutorial/sql-update.html
http://www.w3schools.com/sql/sql_update.asp
|
ประวัติการแก้ไข 2015-10-08 18:35:55
 |
 |
 |
 |
Date :
2015-10-08 18:33:22 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มันerror หลังจากกดupdate แล้วมาinsertข้อมูลใหม่
แต่แทนที่จะเข้าinsert แต่มันดันเข้าupdateแทน
ดังนั้นควรแก้อย่างไร ตามที่คุณTOR_CHEMISTRYบอก
|
 |
 |
 |
 |
Date :
2015-10-08 18:55:30 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
หลังจากupdateแล้วมาinsert พอกดบันทึก แล้วขึ้นpopupว่า อัพเดทเรียบร้อยแล้ว และมาขึ้นpopupที่เป็นเลขIDของแถวที่เพิ่งupdateไป(จากโค้ดMsgbox(Me.semat.Tag)
แล้วerrorดังรูป
>>>> ขึ้นpopupที่เป็นเลขIDของแถวที่เพิ่งupdate
>>> แสดงว่าไม่ได้เคลียร์ค่า
ลองเพิ่มคำสั่ง Me.semat.Tag = ""
เข้าไปหลังจากที่ update เสร็จแล้ว
|
 |
 |
 |
 |
Date :
2015-10-09 07:50:19 |
By :
fonfire |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Error มันบอกอยู่แล้วครับว่าไม่ได้เป็นตามที่บอกมา
มันเป็นที่ syntex Update ต่างห่าง

มันerror หลังจากกดupdate แล้วมาinsertข้อมูลใหม่
แต่แทนที่จะเข้าinsert แต่มันดันเข้าupdateแทน
ลอง alerd Me.semat.Tag & "" = "" มาดูครับ
ว่าตรงกับที่คุณหวังไว้ไม๊ คิดว่าน่าจะสลับกัน
|
 |
 |
 |
 |
Date :
2015-10-09 07:56:43 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณ คุณFONFIREมากๆเลยได้แล้ว
|
 |
 |
 |
 |
Date :
2015-10-09 17:45:55 |
By :
peemes101 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|