 |
|
ช่วยที่ครับ update แล้วมันไม่ขึ้นใน gridview ต้องแก้ code ตรงไหนบ้างครับช่วยที |
|
 |
|
|
 |
 |
|
มี Error อะไรหรือเปล่าครับ หรือไม่ลอง Debug ดูครับ 
|
 |
 |
 |
 |
Date :
2011-07-27 09:17:17 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองแล้วครับ ไม่มีขึ้นอะไรเลย
นี้ครับ ข้อมูลเต็มๆ
Code (VB.NET)
Private Sub Btn_u_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_u.Click
If MessageBox.Show("คุณต้องการแก้ไขข้อมูลนี้หรือไม่", "ข้อความเตือน", MessageBoxButtons.YesNo, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2) = Windows.Forms.DialogResult.Yes Then
edit_Data()
ShowData()
MessageBox.Show("แก้ไขข้อมูลเสร็จสมบูรณ์", "ข้อความ", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub edit_Data()
Dim sqlQuery1 As String
Dim conn As New OleDbConnection
sqlQuery1 = "UPDATE locker SET " _
& "CODE='" & Txt_c.Text & "'," _
& "NAME='" & Txt_n.Text & "'," _
& "DEP='" & Txt_dep.Text & "'," _
& "LOCKER='" & Txt_locker.Text & "'" _
& "WHERE NO='" & Txt_no.Text & "'"
'MessageBox.Show(sqlQuery1)
Dim com As New OleDbCommand()
With com
.CommandType = CommandType.Text
.CommandText = sqlQuery1
.Connection = conn
.ExecuteNonQuery()
End With
End Sub
Private Sub DataGridView1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Click
Try
Txt_no.Text = DataGridView1.CurrentRow.Cells(0).Value.ToString
Txt_c.Text = DataGridView1.CurrentRow.Cells(1).Value.ToString
Txt_n.Text = DataGridView1.CurrentRow.Cells(2).Value.ToString
Txt_dep.Text = DataGridView1.CurrentRow.Cells(3).Value.ToString
Txt_locker.Text = DataGridView1.CurrentRow.Cells(4).Value.ToString
Btn_u.Enabled = True
'cmdClear.Enabled = True
Btn_d.Enabled = True
Btn_a.Enabled = True
Catch
End Try
End Sub
|
 |
 |
 |
 |
Date :
2011-07-27 09:21:48 |
By :
cantaloop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
คือ มันขึ้นว่า แก้ไขข้อมูลเสร็จสมบูรณ์ แต่ ใน data มันไม่ update ให้นะครับ
|
 |
 |
 |
 |
Date :
2011-07-27 09:23:43 |
By :
cantaloop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลอง debug ดูค่าตัวแปร sqlQuery1 ครับ
|
 |
 |
 |
 |
Date :
2011-07-27 09:27:02 |
By :
webmaster |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เปลียนตัวแปรแล้ว มันก็ไม่ขึ้นเหมือนเดิม ครับ กด update พอมันรับค่าไปแล้ว แต่ไม่เปลียน ค่าที่เรา จะให้มันเปลียนนะครับ
|
ประวัติการแก้ไข 2011-07-27 09:37:29
 |
 |
 |
 |
Date :
2011-07-27 09:33:06 |
By :
cantaloop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้ไหมครับ ช่วยที่ ติดแค่ตรงนี้เท่านั้น
|
 |
 |
 |
 |
Date :
2011-07-27 10:01:01 |
By :
cantaloop |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|