I want to update in the "CIU" column in the database "GSDTS" and retrieve the data or values from the database "IFGTS" in the column "PRSOBNET" based on the conditions of the "ITM" column and the "GDN" column or warehouse. Do I have to do sql update or insert to please recommend the solution because I sql command in the code does not work at all and how can the sql command solution work? thanks jack
Sub InsertIntoGsdts()
Try
Dim sql As String = "INSERT INTO GSDTS (CIU) SELECT t1.PRSOBNET FROM IFGTS t1 WHERE NOT EXISTS(SELECT ITM FROM GSDTS t2 WHERE t2.ITM = t1.ITM) AND GDN = 'A.04.01.002.001'"
Using conn As New OleDbConnection(cn),
cmd As New OleDbCommand(sql, conn)
conn.Open()
cmd.ExecuteNonQuery()
End Using
Catch myerror As Exception
MessageBox.Show("Error: " & myerror.Message)
End Try
End Sub
Private Sub SQL2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SQL2.Click
InsertIntoGsdts()
fillDataGridView1()
End Sub