Professional Web Applications Themes

Set Command object ActiveConnection property to Nothing? - ASP

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

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

  3. #3

    Default Re: Set Command object ActiveConnection property to Nothing?

    On Mon, 20 Oct 2003 16:44:33 -0400, "Bob Barrows"
    <reb01501NOyahoo.SPAMcom> wrote:
    in <OOlZ7r0lDHA.2732TK2MSFTNGP11.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

Similar Threads

  1. Replies: 0
    Last Post: November 13th, 11:04 AM
  2. Passing an object as a property???
    By Henri in forum ASP.NET Building Controls
    Replies: 1
    Last Post: May 18th, 05:12 PM
  3. Access to Session Object Property
    By Dorsa in forum ASP.NET Security
    Replies: 1
    Last Post: December 17th, 06:45 PM
  4. recordset ActiveConnection Close
    By Becky Calder in forum Macromedia Dreamweaver
    Replies: 0
    Last Post: July 18th, 02:53 PM
  5. Object property question
    By Adrian in forum Microsoft SQL / MS SQL Server
    Replies: 6
    Last Post: July 9th, 03:56 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