Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Command Object Vs Connection Object

Author  Topic 

zippy
Yak Posting Veteran

69 Posts

Posted - 2001-10-22 : 19:05:08
I have been playing with executing a stored procedure through the command object and also through the connection object.
I was under the impression that the command object is the best to use, however the connection onject (in this case) seems to perform better (roughly twice as fast as the command object)
Here are the scripts (connection then command)

Set cn = Server.CreateObject("ADODB.Connection")
cn.Open cnGeneral
Set rs = cn.Execute ("exec GetActiveCountriesResults")
if rs.EOF then
Results = 0
else
Results = 1
arrDetails = rs.GetRows()
end if
Set rs = nothing
cn.Close
Set cn = nothing

Set cmd = Server.CreateObject("ADODB.Command")
with cmd
.ActiveConnection = cnGeneral
.CommandText = "GetActiveCountriesResults"
.CommandType = adCmdStoredProc
.CommandTimeout = 0
end with
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open cmd
if rs.EOF then
Results = 0
else
Results = 1
arrDetails = rs.GetRows()
end if
Set rs = nothing
Set cmd = nothing

Am I doing something wrong with this script?
should it be faster than the connection object?
which should I use in this case?

Thanks

Check out the worlds fastest computers at http://www.ocgurus.com
   

- Advertisement -