Set Command object ActiveConnection property to Nothing?

Ask a Question related to ASP, Design and Development.

  1. #1

    Default Set Command object ActiveConnection property to Nothing?

    I was looking for a general consensus as to whether the ActiveConnection property of the command
    object should be set to Nothing or whether it's sufficient to set the command object itself to
    nothing.

    I also seem to be forced to use the Parameters.Append method, since I was unable to make the
    statement Set rs = .Execute(,Array(strShowID,strSort),adCmdStoredProc ) work without error.
    I'm guessing that while they're both Variants, one is a numeric and the other a string? The above
    statement yields :

    Parameter object is improperly defined. Inconsistent or incomplete information was provided.

    <%With cmd
    .CommandText = "show_ShowEntries"
    .Parameters.Append .CreateParameter("@Sort", adVarChar, adParamInput, 7, strSort)
    Set rs = .Execute(,,adCmdStoredProc)
    Set .ActiveConnection = Nothing <---- is this necessary/advisable ?
    End With
    Set cmd = Nothing <---- or is this sufficient ?
    With rs
    If (NOT .EOF) Then
    Dim ar
    ar = .GetRows
    Set rs = .NextRecordset
    Dim intTotalEntries
    intTotalEntries = rs(0)
    End If
    End With
    rs.Close: Set rs = Nothing: cn.Close: Set cn = Nothing
    Stefan Berglund Guest

  2. Similar Questions and Discussions

    1. #29234 [Com]: empty($object->property) incorrect when property has access overloaded (__get)
      ID: 29234 Comment by: phpbugs at thunder-2000 dot com Reported By: chrissy at codegoat dot com Status: No...
    2. Passing an object as a property???
      Is it possible to do sth like this ? Page's code part: Private xmlObj As New XmlDocument(......)...
    3. DefinedSize property of Field object
      Hi all, why is the DefinedSize of the Field object of type adInteger returning the value 4 and the same property on a adVarWChar type field (Text...
    4. recordset ActiveConnection Close
      Does anybody know why Dreamweaver does not automatically close the ActiveConnection for recordsets in they way that it closes recordsets...
    5. Object property question
      SQL Server 2000 If I run the following query using Query Analyser from the 'testdata' database the OBJECTPROPERTY of user tables is 1. But if I...
  3. #2

    Default Re: Set Command object ActiveConnection property to Nothing?

    Stefan Berglund wrote:
    > I was looking for a general consensus as to whether the
    > ActiveConnection property of the command object should be set to
    > Nothing or whether it's sufficient to set the command object itself
    > to nothing.
    You don't have to set it to nothing
    >
    > I also seem to be forced to use the Parameters.Append method, since I
    > was unable to make the statement Set rs =
    > .Execute(,Array(strShowID,strSort),adCmdStoredProc ) work without
    > error.
    > I'm guessing that while they're both Variants, one is a numeric and
    > the other a string? The above statement yields :
    >
    > Parameter object is improperly defined. Inconsistent or incomplete
    > information was provided.
    Since your stored procedure has no output parameters, and you don't seem to
    be interested in reading the value of the Return parameter, I suggest you
    don't use an explicit Command object at all. Try this (assuming your
    connection object variable is called cn):

    set rs=server.createobject("adodb.recordset")
    cn.show_ShowEntries strSort, rs

    If you're executing a procedure that does not return records, just leave off
    the rs argument:
    cn.NoRecords parmval1, ..., parmvalN

    HTH,
    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 Barrows Guest

  4. #3

    Default Re: Set Command object ActiveConnection property to Nothing?

    On Mon, 20 Oct 2003 16:44:33 -0400, "Bob Barrows"
    <reb01501@NOyahoo.SPAMcom> wrote:
    in <OOlZ7r0lDHA.2732@TK2MSFTNGP11.phx.gbl>
    >Stefan Berglund wrote:
    >> I was looking for a general consensus as to whether the
    >> ActiveConnection property of the command object should be set to
    >> Nothing or whether it's sufficient to set the command object itself
    >> to nothing.
    >
    >You don't have to set it to nothing
    >
    >>
    >> I also seem to be forced to use the Parameters.Append method, since I
    >> was unable to make the statement Set rs =
    >> .Execute(,Array(strShowID,strSort),adCmdStoredProc ) work without
    >> error.
    >> I'm guessing that while they're both Variants, one is a numeric and
    >> the other a string? The above statement yields :
    >>
    >> Parameter object is improperly defined. Inconsistent or incomplete
    >> information was provided.
    >
    >Since your stored procedure has no output parameters, and you don't seem to
    >be interested in reading the value of the Return parameter, I suggest you
    >don't use an explicit Command object at all. Try this (assuming your
    >connection object variable is called cn):
    >
    >set rs=server.createobject("adodb.recordset")
    >cn.show_ShowEntries strSort, rs
    >
    >If you're executing a procedure that does not return records, just leave off
    >the rs argument:
    >cn.NoRecords parmval1, ..., parmvalN
    >
    >HTH,
    >Bob Barrows
    Most excellent Bob, thanks. I had searched MSDN unsuccessfully
    for an example that would allow execution off the connection
    object with parameters and was more or less resigned to having to
    use the command object. I also searched the FAQ but I guess I
    either wasn't persistent enough or didn't use the right search
    criteria, since I just saw the EXEC @param=value option which at
    least comes close. I guess I just should have tried it.

    Now I can chop out more code. <g> Thanks again.
    Stefan Berglund Guest

Posting Permissions

  • You may not post new threads
  • You may 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