This is my code for insert and update statement:
For i = 0 To lvFabric1.Items.Count - 1
strQ4 = ""
strQ4 = strQ4 & "INSERT into js_det(LINE_NO, FABRIC1, FABRIC2, `DESC`) SELECT LPAD('" & i + 1 & "',2, '0'), '" & lvFabric1.Items(i).Text & "','sdf', `DESC` from rm_inv where ITEM_CODE = '" & lvFabric1.Items(i).Text & "'"
strQ5 = ""
strQ5 = strQ5 & "UPDATE js_det set TRAN_NO = (SELECT JS_TRAN FROM counter) where Fabric1 = '" & lvFabric1.Items(i).Text & "'"
cmd.CommandText = strQ4
cmd.ExecuteNonQuery()
cmd.CommandText = strQ5
cmd.ExecuteNonQuery()
Next
What the problem here is that its getting slower if it is looping 5 times and above, it take above 3 second. How can I speed up this code? or is there another way?
Thanks for the help.