SQLTeam.com | Weblogs | Forums

What is the difference between Connection.Execute and Command.Execute in ADO?

sql2008

#1

Hi,

I am using ADO/Visual C++ to access SQL Server database
engine. I find both the connection and command object has Execute method, as
below:

https://msdn.microsoft.com/en-us/library/ms675023(v=vs.85).aspx
(ADO Connection)

https://msdn.microsoft.com/en-us/library/ms681559(v=vs.85).aspx
(ADO Command)

Both will execute the SQL query and return a recordset.

In that case, what is the difference between them and why MS
will provide two functions with same functionalities?


#2

They're not the same. Read the links you posted. I'm sure that there are other subtleties but one returns a result set... the other can return a result set, a stream, or NOTHING.