Dim Conn As New Sql Connection Dim da

  • Slides: 8
Download presentation

ประกาศตวแปรสาธารณะ Dim Conn As New Sql. Connection Dim da As New Sql. Data. Adapter

ประกาศตวแปรสาธารณะ Dim Conn As New Sql. Connection Dim da As New Sql. Data. Adapter Dim ds As New Data. Set Dim cmd As New Sql. Command

หนาฟอรม Private Sub Form 6_Load(By. Val sender As System. Object, By. Val e As

หนาฟอรม Private Sub Form 6_Load(By. Val sender As System. Object, By. Val e As System. Event. Args) Handles My. Base. Load Connection. String = "Data Source=(local); Initial Catalog=test; Integrated Security=True" Conn. Open() showcus() Conn. Close() End Sub

นำขอมลจาก datagrid Private Sub Data. Grid. View 1_Cell. Content. Click(By. Val sender As System.

นำขอมลจาก datagrid Private Sub Data. Grid. View 1_Cell. Content. Click(By. Val sender As System. Object, By. Val e As System. Windows. Forms. Data. Grid. View. Cell. Event. Args) Handles Data. Grid. View 1. Cell. Content. Click Dim a, b As String id = Data. Grid. View 1. Current. Row. Cells(0). Value name = Data. Grid. View 1. Current. Row. Cells(1). Value txtid. Text = id txtname. Text = name txtid. Enabled = False End Sub

คำสงแกไขขอมล Dim id, name As String Dim sqlupdate As String id = txtid. Text

คำสงแกไขขอมล Dim id, name As String Dim sqlupdate As String id = txtid. Text name = txtname. Text Connection. String = "Data Source=(local); Initial Catalog=test; Integrated Security=True" Conn. Open() sqlupdate = "update cus set name='" & name & "' where id='" & id & "'" With cmd . Command. Type = Command. Type. Text . Command. Text = sqlupdate . Connection = Conn . Execute. Non. Query() End With

 Message. Box. Show("การแกไขขอมลเรยบรอย txtid. Enabled = True ds. Clear() showcus() Conn. Close() ")

Message. Box. Show("การแกไขขอมลเรยบรอย txtid. Enabled = True ds. Clear() showcus() Conn. Close() ")