I have two tables A and B shown.
Table A
HoleNo Depth_from Depth_to
A1 1 2
A1 3 4
A1 5 6
Table B
HoleNo Depth_from Depth_to
A1
A1
A1
Now How do I update table B so that it looks like table A
Note that no changes must be made to table A.
I have tried to assign id's to table B so that I do the update based on the unique id's, but since I am not to make any changes to table A I am finding it very difficult.
this is my code
I first save all HoleNo into B from A
sqlSTR = "SELECT * FROM A"
ExecuteSQLQuery(sqlSTR) 'call function to execute the query
For Each row1 As DataRow In sqlDT.Rows
sqlSTR = "INSERT INTO B (HoleNo) VALUES ('" & row1(0) & "')"
ExecuteSQLQuerylocal(sqlSTR) 'call function to execute the query
Next
So after inserting all HoleNo then I try to update the rest of the fields with this code
sqlSTR = "SELECT * FROM A"
ExecuteSQLQuery(sqlSTR) 'call function to execute the query
For Each row1 As DataRow In sqlDT.Rows
sqlSTR = "UPDATE B SET Depth_from ='" & row(0) & "' WHERE HoleNo ='" & row(0) & "'"
ExecuteSQLQuerylocal(sqlSTR)
Next