I've just started to learn VB.Net and SQL. Now I'm creating my first software but I have a problem: I have two tables in my database and I managed to transfer data from table1 to table2. How can I just insert specific rows from table1 to table2. I don't want to copy all the data in table1 to table2; I just want to copy the selected rows.
Here's my code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
cmd.CommandText = "INSERT INTO returns(Department, Purpose, Item_details, Requested_by, Approved_by, ReturnDate) SELECT Department, Purpose, Items_Details, Requested_by, Approved_by, Date FROM borrow WHERE Date= '" & Today.Date.ToShortDateString & "';"
cmd.Connection = con
Try
con.Open()
cmd.ExecuteNonQuery()
Finally
con.Close()
End Try
End Sub
I have a listbox which has a sourcebinding which is borrow
and I only want the selected items single row to be transferred to my table returns
but I don't know how to do it. Whenever I click the button, everything in table borrow
will be copied to table returns
.