Command Vs Connection Object

Command Vs Connection Object

am 12.10.2004 20:36:25 von wk6pack

Hi,

I was wondering which is better to use? I'm accessing two different
databases in my asp page. One thru ODBC and the other MS Jet.
Should I use a command and a connection object to connect to the two
databases?
Or should I use two connection objects?

thanks,
Will

Re: Command Vs Connection Object

am 12.10.2004 20:46:43 von reb01501

wk6pack wrote:
> Hi,
>
> I was wondering which is better to use? I'm accessing two different
> databases in my asp page. One thru ODBC and the other MS Jet.
> Should I use a command and a connection object to connect to the two
> databases?
> Or should I use two connection objects?
>
> thanks,
> Will

A Command object is ALWAYS involved, even if you do not explicitly create
one.

It looks to me as if you need two Connection objects, since you are
connecting to two databases. Unless you are not planning to be connected to
both of them at the same time...

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Command Vs Connection Object

am 12.10.2004 20:57:17 von wk6pack

thanks Bob.

Will

"Bob Barrows [MVP]" wrote in message
news:%23oh1dwIsEHA.556@tk2msftngp13.phx.gbl...
> wk6pack wrote:
> > Hi,
> >
> > I was wondering which is better to use? I'm accessing two different
> > databases in my asp page. One thru ODBC and the other MS Jet.
> > Should I use a command and a connection object to connect to the two
> > databases?
> > Or should I use two connection objects?
> >
> > thanks,
> > Will
>
> A Command object is ALWAYS involved, even if you do not explicitly create
> one.
>
> It looks to me as if you need two Connection objects, since you are
> connecting to two databases. Unless you are not planning to be connected
to
> both of them at the same time...
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>

Re: Command Vs Connection Object

am 13.10.2004 07:56:39 von Ken Schaefer

I think Bob means that a "connection object" is always involved.

Connection objects are for connecting to database
Command objects are for executing commands
Recordset objects are for holding resultsets.

So, you always need a connection object (or one will be created for you if
required). If you are returning results, you need a recordset. Command
objects can be used to specify input/output parameters to be sent to the
datastore.

Cheers
Ken

"wk6pack" wrote in message
news:ONGWy0IsEHA.1644@tk2msftngp13.phx.gbl...
> thanks Bob.
>
> Will
>
> "Bob Barrows [MVP]" wrote in message
> news:%23oh1dwIsEHA.556@tk2msftngp13.phx.gbl...
>> wk6pack wrote:
>> > Hi,
>> >
>> > I was wondering which is better to use? I'm accessing two different
>> > databases in my asp page. One thru ODBC and the other MS Jet.
>> > Should I use a command and a connection object to connect to the two
>> > databases?
>> > Or should I use two connection objects?
>> >
>> > thanks,
>> > Will
>>
>> A Command object is ALWAYS involved, even if you do not explicitly create
>> one.
>>
>> It looks to me as if you need two Connection objects, since you are
>> connecting to two databases. Unless you are not planning to be connected
> to
>> both of them at the same time...
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get a
>> quicker response by posting to the newsgroup.
>>
>>
>
>

Re: Command Vs Connection Object

am 13.10.2004 13:03:16 von reb01501

No, I meant what I said. A Command object is always used to send command to
a database. Even when you use the connection's Execute method to execute the
statement, in which case an implicit Command object is used.

Bob Barrows

Ken Schaefer wrote:
> I think Bob means that a "connection object" is always involved.
>
> Connection objects are for connecting to database
> Command objects are for executing commands
> Recordset objects are for holding resultsets.
>
> So, you always need a connection object (or one will be created for
> you if required). If you are returning results, you need a recordset.
> Command objects can be used to specify input/output parameters to be
> sent to the datastore.
>
> Cheers
> Ken
>
> "wk6pack" wrote in message
> news:ONGWy0IsEHA.1644@tk2msftngp13.phx.gbl...
>> thanks Bob.
>>
>> Will
>>
>> "Bob Barrows [MVP]" wrote in message
>> news:%23oh1dwIsEHA.556@tk2msftngp13.phx.gbl...
>>> wk6pack wrote:
>>>> Hi,
>>>>
>>>> I was wondering which is better to use? I'm accessing two
>>>> different databases in my asp page. One thru ODBC and the other MS
>>>> Jet. Should I use a command and a connection object to connect to the
>>>> two databases?
>>>> Or should I use two connection objects?
>>>>
>>>> thanks,
>>>> Will
>>>
>>> A Command object is ALWAYS involved, even if you do not explicitly
>>> create one.
>>>
>>> It looks to me as if you need two Connection objects, since you are
>>> connecting to two databases. Unless you are not planning to be
>>> connected to both of them at the same time...
>>>
>>> --
>>> Microsoft MVP -- ASP/ASP.NET
>>> Please reply to the newsgroup. The email account listed in my From
>>> header is my spam trap, so I don't check it very often. You will
>>> get a quicker response by posting to the newsgroup.

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Re: Command Vs Connection Object

am 13.10.2004 14:52:18 von Ken Schaefer

Interesting - and how can we see that?

Cheers
Ken


"Bob Barrows [MVP]" wrote in message
news:%23LfP6QRsEHA.2252@TK2MSFTNGP11.phx.gbl...
> No, I meant what I said. A Command object is always used to send command
> to a database. Even when you use the connection's Execute method to
> execute the statement, in which case an implicit Command object is used.
>
> Bob Barrows
>
> Ken Schaefer wrote:
>> I think Bob means that a "connection object" is always involved.
>>
>> Connection objects are for connecting to database
>> Command objects are for executing commands
>> Recordset objects are for holding resultsets.
>>
>> So, you always need a connection object (or one will be created for
>> you if required). If you are returning results, you need a recordset.
>> Command objects can be used to specify input/output parameters to be
>> sent to the datastore.
>>
>> Cheers
>> Ken
>>
>> "wk6pack" wrote in message
>> news:ONGWy0IsEHA.1644@tk2msftngp13.phx.gbl...
>>> thanks Bob.
>>>
>>> Will
>>>
>>> "Bob Barrows [MVP]" wrote in message
>>> news:%23oh1dwIsEHA.556@tk2msftngp13.phx.gbl...
>>>> wk6pack wrote:
>>>>> Hi,
>>>>>
>>>>> I was wondering which is better to use? I'm accessing two
>>>>> different databases in my asp page. One thru ODBC and the other MS
>>>>> Jet. Should I use a command and a connection object to connect to the
>>>>> two databases?
>>>>> Or should I use two connection objects?
>>>>>
>>>>> thanks,
>>>>> Will
>>>>
>>>> A Command object is ALWAYS involved, even if you do not explicitly
>>>> create one.
>>>>
>>>> It looks to me as if you need two Connection objects, since you are
>>>> connecting to two databases. Unless you are not planning to be
>>>> connected to both of them at the same time...
>>>>
>>>> --
>>>> Microsoft MVP -- ASP/ASP.NET
>>>> Please reply to the newsgroup. The email account listed in my From
>>>> header is my spam trap, so I don't check it very often. You will
>>>> get a quicker response by posting to the newsgroup.
>
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>

Re: Command Vs Connection Object

am 13.10.2004 15:14:41 von reb01501

We can't. The only visible indication is that we are allowed to pass
CommandType arguments in the connection's Execute statement. These arguments
are passed to the implicit Command object.

The only reason I know this is that David Sceppa wrote about it in his
"Programming ADO" book. I seem to recall Bill Vaughn mentioning it in his
book as well. Unfortunately, both books are unavailable to me at the moment
so I can't cite page numbers.

Bob Barrows

Ken Schaefer wrote:
> Interesting - and how can we see that?
>
> Cheers
> Ken
>
>
> "Bob Barrows [MVP]" wrote in message
> news:%23LfP6QRsEHA.2252@TK2MSFTNGP11.phx.gbl...
>> No, I meant what I said. A Command object is always used to send
>> command to a database. Even when you use the connection's Execute
>> method to execute the statement, in which case an implicit Command
>> object is used.
>>
>> Bob Barrows
>>
>> Ken Schaefer wrote:
>>> I think Bob means that a "connection object" is always involved.
>>>
>>> Connection objects are for connecting to database
>>> Command objects are for executing commands
>>> Recordset objects are for holding resultsets.
>>>
>>> So, you always need a connection object (or one will be created for
>>> you if required). If you are returning results, you need a
>>> recordset. Command objects can be used to specify input/output
>>> parameters to be sent to the datastore.
>>>
>>> Cheers
>>> Ken
>>>
>>> "wk6pack" wrote in message
>>> news:ONGWy0IsEHA.1644@tk2msftngp13.phx.gbl...
>>>> thanks Bob.
>>>>
>>>> Will
>>>>
>>>> "Bob Barrows [MVP]" wrote in message
>>>> news:%23oh1dwIsEHA.556@tk2msftngp13.phx.gbl...
>>>>> wk6pack wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I was wondering which is better to use? I'm accessing two
>>>>>> different databases in my asp page. One thru ODBC and the other
>>>>>> MS Jet. Should I use a command and a connection object to
>>>>>> connect to the two databases?
>>>>>> Or should I use two connection objects?
>>>>>>
>>>>>> thanks,
>>>>>> Will
>>>>>
>>>>> A Command object is ALWAYS involved, even if you do not explicitly
>>>>> create one.
>>>>>
>>>>> It looks to me as if you need two Connection objects, since you
>>>>> are connecting to two databases. Unless you are not planning to be
>>>>> connected to both of them at the same time...
>>>>>
>>>>> --
>>>>> Microsoft MVP -- ASP/ASP.NET
>>>>> Please reply to the newsgroup. The email account listed in my From
>>>>> header is my spam trap, so I don't check it very often. You will
>>>>> get a quicker response by posting to the newsgroup.
>>
>> --
>> Microsoft MVP - ASP/ASP.NET
>> Please reply to the newsgroup. This email account is my spam trap so
>> I don't check it very often. If you must reply off-line, then remove
>> the "NO SPAM"

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Command Vs Connection Object

am 13.10.2004 19:59:23 von reb01501

Chris Hohmann wrote:
> "Bob Barrows [MVP]" wrote in message
> news:OII2jbSsEHA.3412@TK2MSFTNGP14.phx.gbl...
>> We can't. The only visible indication is that we are allowed to pass
>> CommandType arguments in the connection's Execute statement. These
>> arguments are passed to the implicit Command object.
>>
>> The only reason I know this is that David Sceppa wrote about it in
>> his "Programming ADO" book. I seem to recall Bill Vaughn mentioning
>> it in his book as well. Unfortunately, both books are unavailable to
>> me at the moment so I can't cite page numbers.
>
> Here's an excerpt from the Connection Object documentation:
> http://www.msdn.microsoft.com/library/en-us/ado270/htm/mdobj connection.asp
>
> Note: To execute a query without using a Command object,

Change this to

Note: To execute a query without using an explicit Command object,

and according to what I remember reading, it would be more correct.

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Re: Command Vs Connection Object

am 13.10.2004 20:01:40 von Chris Hohmann

"Bob Barrows [MVP]" wrote in message
news:OII2jbSsEHA.3412@TK2MSFTNGP14.phx.gbl...
> We can't. The only visible indication is that we are allowed to pass
> CommandType arguments in the connection's Execute statement. These
arguments
> are passed to the implicit Command object.
>
> The only reason I know this is that David Sceppa wrote about it in his
> "Programming ADO" book. I seem to recall Bill Vaughn mentioning it in his
> book as well. Unfortunately, both books are unavailable to me at the
moment
> so I can't cite page numbers.

Here's an excerpt from the Connection Object documentation:
http://www.msdn.microsoft.com/library/en-us/ado270/htm/mdobj connection.asp

Note: To execute a query without using a Command object, pass a query string
to the Execute method of a Connection object. However, a Command object is
required when you want to persist the command text and re-execute it, or use
query parameters.

However, I'm inclined to believe Bob's interpretation that an implicit
connection object is being used. He's never steered me wrong before. :-)