Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27350

How to Delete records from one table and same needs to be updated in another table...

$
0
0
Hi, i need help because i'm new to Visual Basic 2010. I have 2 tables with the same fields in MS ACCESS Database 2007 (pending, confirmed) and i am importing data from 1st table to listview control of 1st Form and after selecting entire row if i press Shift+F1 key then selected data appears in text boxes of 2nd form and after editing same needs to be updated in 2nd table.

Here are my codes.....

Private Sub Button1_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim cmd As New OleDbCommand

cmd = New OleDb.OleDbCommand("INSERT INTO confirmed (Name, Address, PhoneNumber) VALUES ('" & NameTxtBox.Text & "', '" & AddTxtBox.Text & "', '" PhnTxtBox.Text & "', connection)
cmd.ExecuteNonQuery()

cmd = New OleDb.OleDbCommand("DELETE * FROM pending WHERE Name = '" & NameTxtBox.Text & "' And Address = '" & AddTxtBox.Text & "' And PhoneNumber= '" PhnTxtBox.Text & "', connection)
cmd.ExecuteNonQuery()

MessageBox.Show("Records updated successfully", "Saved", MessageBoxButtons.OK, MessageBoxIcons.Information)
Me.Close()

End Sub

Can anyone suggest me that do these codes work together? As when i debug codes it seems works fine for 1st time but 2nd time (without stop debugging) when i press again Shift+F1 key and after editing the another records it does not delete from 1st table but it updates records in 2nd table successfully....

Viewing all articles
Browse latest Browse all 27350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>