Professional Web Applications Themes

Command Vs Connection Object - ASP Database

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...

  1. #1

    Default Command Vs Connection Object

    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


    wk6pack Guest

  2. #2

    Default Re: Command Vs Connection Object

    wk6pack wrote: 

    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.


    Bob Guest

  3. #3

    Default Re: Command Vs Connection Object

    thanks Bob.

    Will

    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:%phx.gbl... 
    >
    > 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[/ref]
    to 


    wk6pack Guest

  4. #4

    Default Re: Command Vs Connection Object

    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" <bc.ca> wrote in message
    news:phx.gbl... 
    >>
    >> 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[/ref]
    > to 
    >
    >[/ref]


    Ken Guest

  5. #5

    Default Re: Command Vs Connection Object

    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: [/ref][/ref]

    --
    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"


    Bob Guest

  6. #6

    Default Re: Command Vs Connection Object

    Interesting - and how can we see that?

    Cheers
    Ken


    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:%phx.gbl... [/ref]
    >
    > --
    > 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"
    >[/ref]


    Ken Guest

  7. #7

    Default Re: Command Vs Connection Object

    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: 
    >>
    >> --
    >> 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"[/ref][/ref]

    --
    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.


    Bob Guest

  8. #8

    Default Re: Command Vs Connection Object

    Chris Hohmann wrote: 
    >
    > Here's an excerpt from the Connection Object doentation:
    > http://www.msdn.microsoft.com/library/en-us/ado270/htm/mdobjconnection.asp
    >
    > Note: To execute a query without using a Command object,[/ref]

    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.


    Bob Guest

  9. #9

    Default Re: Command Vs Connection Object

    "Bob Barrows [MVP]" <SPAMcom> wrote in message
    news:phx.gbl... 
    arguments 
    moment 

    Here's an excerpt from the Connection Object doentation:
    http://www.msdn.microsoft.com/library/en-us/ado270/htm/mdobjconnection.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. :-)


    Chris Guest

Similar Threads

  1. Can you put an Insert Command object in a loop?
    By Tim Pollard in forum Dreamweaver AppDev
    Replies: 0
    Last Post: April 12th, 09:47 PM
  2. ASP Command Object Syntax Errors
    By fiddlestyx in forum Dreamweaver AppDev
    Replies: 1
    Last Post: February 18th, 07:50 PM
  3. Command Object and RecordSet ASP
    By Sean in forum ASP Database
    Replies: 4
    Last Post: February 26th, 12:36 PM
  4. Replies: 2
    Last Post: October 20th, 09:48 PM
  5. ADO Error with Command Object
    By r in forum Macromedia Dreamweaver
    Replies: 2
    Last Post: July 30th, 01:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139