Is there a better solution (using less code) for the following code snippet. It is something that I find myself doing a lot of in VB6 and was hoping to trim it down.
As I understand it Connection.Execute will not work
SQL = 'SELECT SomeID FROM TableA' RecordSet.Open SQL, Connection, adOpenStatic, adLockOptimistic, adCmdText SomeID = RecordSet.Fields(0).Value RecordSet.Close SQL = 'SELECT AnotherID FROM TableB' RecordSet.Open SQL, Connection, adOpenStatic, adLockOptimistic, adCmdText AnotherID = RecordSet.Fields(0).Value RecordSet.Close
This isn’t a functional issue just looking to see if there is a tidier way.
The default parameters for both
RecordSet.Open()andConnection.Execute()are:You use different settings, but there is no apparent reason not to go with the defaults in your case.
I don’t know why you think that
Connection.Execute()will not work, especially since you seem to have static SQL: