Im in a wee bit a jam. I use INSERT SELECT statement with an OleDb Command (see code below). This SELECT statement seeks from two different tables. My problem is this:
if the first table(s) contain data and the ExecuteNonQuery is done the other INSERT SELECT shuold be skipped.
How can I check if the first cmd.ExecutenonQuery has inserted some actual data? It performs the Execute as if there is data, but actually doesnt insert anything.
if the first table(s) contain data and the ExecuteNonQuery is done the other INSERT SELECT shuold be skipped.
How can I check if the first cmd.ExecutenonQuery has inserted some actual data? It performs the Execute as if there is data, but actually doesnt insert anything.
Code:
Try
OleDbConnection1.Open()
For Each item As String In ListBox2.Items
Dim cmd As OleDbCommand
Dim insrt_str As String
insrt_str = "INSERT INTO NMYLIB.BMNS_PF (CSCDNR, CSCHDNAME, B00CA1, B00CA2) SELECT CSCDNR, CSCHDNAME, F54A01, F54A02 FROM LBZVD02.CDCS00, LBEOD03.BMF00P, LBEOD03.BMF40P, LBEOD03.SDF99P, LBEOD03.CAFIXP, LBEOD03.CAF54P WHERE CSACCOPU = B40OPU AND CSIBSACC = B40ACC AND B40CLT = B00CLT AND CSCDTYPE = ATMC AND CSCDSTAT = *ACT AND B40STS <> C AND CSIBSACC = FIXTAC AND B00CLT = F54CLT AND F54RPT = 112N AND F54SEQ = 1 AND CSCDNR = 00005940" & item & ""
cmd = New OleDbCommand(insrt_str, OleDbConnection1)
cmd.ExecuteNonQuery()
if actual data inserted skip this next chunk of code
Dim cmd1 As OleDbCommand
Dim insrt_str1 As String
insrt_str1 = "INSERT INTO NMYLIB.BMNS_PF (CSCDNR, CSCHDNAME, B00CA1, B00CA2) SELECT CSCDNR, CSCHDNAME, b00ca1, b00ca2 FROM LBZVD02.CDCS00, LBDATA.LMF00P, LBEOD03.BMF40P, LBEOD03.CAFIXP WHERE CSACCOPU = B40OPU AND CSIBSACC = B40ACC AND B40CLT = B00CLT AND CSCDTYPE = ATMC AND CSCDSTAT = *ACT AND B40STS NOT IN (C) AND csibsacc = FIXTAC AND CSCDNR = 00005940" & item & ""
cmd1 = New OleDbCommand(insrt_str1, OleDbConnection1)
cmd1.ExecuteNonQuery()
Next
OleDbConnection1.Close()
Catch ex As Exception
End Try