I tried bringing the open and close statements out, but then it doesnt get myOdbcCommand. Is there a more efficient way to write this? This ran for 45 minutes before thowing an error. It got though most of the tables.
VB Code:
For iTable = 1 To 12 For iCounter = 0 To (ds.Tables(0).Rows.Count - 1) If (ds.Tables(0).Rows(iCounter).Item("U_GAS_SERV") <> 0) Then iGasServ = ds.Tables(0).Rows(iCounter).Item("U_GAS_SERV") Dim myDeleteStatement As String = "DELETE * FROM GSV00" & iTable & "T WHERE GSV001T.U_GAS_SERV = " & iGasServ Dim myOdbcCommand As New OdbcCommand(myDeleteStatement, gsvConnection) 'Opens the db connection gsvConnection.Open() 'Excutes the delete statement myOdbcCommand.ExecuteNonQuery() 'Closes connection myOdbcCommand.Connection.Close() End If Next MessageBox.Show("Done with " & iTable) Next




Reply With Quote