SQL Server Performance

fill recordset via execute command

Discussion in 'T-SQL Performance Tuning for Developers' started by phvos, Mar 19, 2003.

  1. phvos New Member

    We are "restyling" our ado classes.
    I wondered what the best way is to open/fill a recordset...

    Just via oRec.Open() or via oRec = oCommand.Execute()

    Considering a. performance and b. error handling

  2. trifunk New Member

    It's just a question of personal style really.
    You can pass a command object to the recordset.open method or you can set it to the results of a command there is no significant performance gain of one over the other. If you use the recordset.open method with a sql string as the source then behind the scenes ADO will actually create its own command object and execute it which is exactly the same as using command.execute.

    As far as error handling is concerned there isn't I don't think there's any difference either, if you're using a connection object then all errors should be reported in the Errors collection in the connection object regardless of which way you execute your commands.

    I use commands most of the time because they're great for setting up parameters for stored procedures and make the code a little more structured and readable.



    World Domination Through Superior Software
  3. Argyle New Member

    And if you are in a web environment you should in 99% of the cases return all queries as clientside disconnected recordsets for best performance.


Share This Page