Sub delete()
Dim strDelete As String = ""
Dim strDelete1 As String = ""
Try
If MsgBox("คุณต้องการลบข้อมูล ID: " & txttr_id.Text, vbYesNo + vbQuestion, "คำเตือน") = vbYes Then
MessageBox.Show("ลบข้อมูลเรียบร้อยแล้ว", "ยืนยัน")
strDelete = "delete from Treatment where t_id = '" & txttr_id.Text & "'"
connect()
Dim cm As New OleDbCommand
With cm
.Connection = conn
.CommandType = CommandType.Text
.CommandText = strDelete
.ExecuteNonQuery()
End With
strDelete1 = "delete from Table_Treat where t_id = 't_id'"
connect()
Dim cm1 As New OleDbCommand
With cm1
.Connection = conn
.CommandType = CommandType.Text
.CommandText = strDelete1
.ExecuteNonQuery()
End With
cleartxt()
showdata()
status = 0
flag = 0
Else
cleartxt()
status = 0
flag = 0
MessageBox.Show("ยกเลิกการลบข้อมูล", "ทำการยืนยัน")
End If
btntr_add.Enabled = True
btntr_clear.Enabled = True
btntr_edit.Enabled = False
btntr_delete.Enabled = False
btntr_save.Enabled = False
Catch ex As Exception
MessageBox.Show("เกิดข้อผิดพลาด :" & ex.Message & "กรุณาตรวจสอบ" & strDelete)
Exit Sub
End Try
End Sub
Tag : .NET, Ms SQL Server 2005, Win (Windows App), VS 2005 (.NET 2.x)