1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| Private Sub BtnRight_Click(sender As Object, e As EventArgs) Handles BtnRight.Click
Dim MyTable As New DataTable
Dim cmd As New OleDbDataAdapter("select * from TEMPTools", cn)
cmd.FillSchema(MyTable, SchemaType.Source)
cmd.Fill(MyTable)
cn.Open()
If MyTable.Rows.Count > 0 Then
For Each R As DataRow In MyTable.Rows
If Len(txtPN1.Text) > 0 Then
If R.Item("ITEM1").ToString = txtPN1.Text Then
Dim Update As New OleDbCommand("UPDATE TEMPTools SET ITEM1='" & "" & "', ITEM2='" & txtPN1.Text & "', ITEM3='" & "" & "', ITEM4='" & "" & "'", cn)
Update.ExecuteNonQuery()
DataGridView1.Refresh()
End If
ElseIf Len(txtPN2.Text) > 0 Then
If R.Item("ITEM2").ToString = txtPN2.Text Then
Dim Update As New OleDbCommand("UPDATE TEMPTools SET ITEM1='" & "" & "', ITEM2='" & "" & "', ITEM3='" & txtPN2.Text & "', ITEM4='" & "" & "'", cn)
Update.ExecuteNonQuery()
DataGridView1.Refresh()
End If
ElseIf Len(txtPN3.Text) > 0 Then
If R.Item("ITEM3").ToString = txtPN3.Text Then
Dim Update As New OleDbCommand("UPDATE TEMPTools SET ITEM1='" & "" & "', ITEM2='" & "" & "', ITEM3='" & "" & "', ITEM4='" & txtPN3.Text & "'", cn)
Update.ExecuteNonQuery()
DataGridView1.Refresh()
End If
Else
End If
Next
End If
Dim MyTable2 As New DataTable
Dim cmd2 As New OleDbDataAdapter("select * from TEMPTools", cn)
cmd2.FillSchema(MyTable2, SchemaType.Source)
cmd2.Fill(MyTable2)
DataGridView1.DataSource = MyTable2
cn.Close()
End Sub |
Partager