473,412 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

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
Jul 19 '05 #1
2 7865
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.
Jul 19 '05 #2
On Mon, 20 Oct 2003 16:44:33 -0400, "Bob Barrows"
<re******@NOyahoo.SPAMcom> wrote:
in <OO**************@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.
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bruno Alexandre | last post by:
Hi guys, withou using SP, I want to be able to add a Parameter to the SQL Query and retrive the Recordset so I can use the Paging property under the recorset object.... how can I do this? I'm...
1
by: Nachi | last post by:
I am getting above error, could pls anyone help me........? Soruce Code : Sub updateOfferCategoryAmounts(ByVal Transid As Long) Dim spComm As Command Set spComm = New Command Dim intCatID...
7
by: What-a-Tool | last post by:
Have no problem getting my select queries to work using this method: strSQL = "SELECT tblUI.IPAdd FROM tblUI WHERE (tblUI.IPAdd =?)" arSPrm = Array(strRemHst) Set rst = cmd.Execute(,arSPrm)...
3
by: Jenni | last post by:
Hi, my simple solution is not so simple. I have done a bit of VB programming, and am now tasked with trying to make access work using VBA, and battling my butt off. This probably has a really...
1
by: tina | last post by:
Hello, I would really appreciate some help. I am still learning VBA and I feel like my brain is fried already. Below I am trying to run a query and do a loop. I actually get the data set but...
0
by: Andre Azevedo | last post by:
Hi all ! I've created a .net serviced component with only one method. This method receive an ADODB.Command object and execute it. The ADODB.Command object is created in the client process. (VB...
4
by: George Shawn | last post by:
Hi, I am running into an extremely frustrating problem and after hours of troubleshooting have not made any progress. When I try to use the ADO Command object to update a table, I receive the...
2
by: Vinayaka B L | last post by:
Hi all, 'm using ADODB.Command object for interactig with database in my application. In the code i'm calling "Execute" method to insert a new row into the database. After writing data into the...
0
ADezii
by: ADezii | last post by:
When you create an ADO Recordset, you should have some idea as to what functionality the Recordset does/does not provide. Some critical questions may, and should, be: Can I add New Records to the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.