[thelist] ADO Question

Ken Schaefer Ken at adOpenStatic.com
Thu Feb 10 19:39:53 CST 2005


Hi there,

Two things:

A) In answer to your question:
objCmd.Parameters("@Message").Value = "your new value"

B) In looking at your code below, you really should be *explicitly* creating
a connection object, and then using a SET to assign that to the
.ActiveConnection property of the command object. This topic has been done to
death on this list. You need to read these pages:
a)
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnmdac/html/
pooling2.asp (Pooling in the Microsoft Data Access Components)

b) http://support.microsoft.com/?id=191572 (INFO: Connection Pool Management
by ADO Objects Called From ASP)

Whilst it is possible to set the connection object that you have implicitly
created to nothing, the code is not particularly self-describing, and it
doesn't return the connection to the pool.

<%
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open your_conn_string

With objCmd
	Set .ActiveConnection = objConn
	...
	...
End With

objConn.Close
Set objConn = nothing
%>

Cheers
Ken


: -----Original Message-----
: From: thelist-bounces at lists.evolt.org
[mailto:thelist-bounces at lists.evolt.org] On
: Behalf Of Sam
: Sent: Thursday, 10 February 2005 11:15 AM
: To: thelist at lists.evolt.org
: Subject: [thelist] ADO Question
: 
: I have the following ASP / ADO code:
: 
:     Set objCmd = CreateObject("ADODB.Command")
:     ' Read the recordset of emails to be sent
:     With objCmd
:         .ActiveConnection = ConnString
:         .CommandType = adCmdStoredProc
:         .CommandText = "dbo.EM_SendEmailJob" 'Our Stored procedure
:         .Parameters.Append .CreateParameter ("RETURN_VALUE", adInteger,
: adParamReturnValue)
:         .Parameters.Append .CreateParameter ("@RecordCount", adInteger,
: adParamInput, , intMaxRecords) ' 0 = all records, N = Max recordset size
:         .Parameters.Append .CreateParameter ("@Message", adVarchar,
: adParamInput, 1000, strDisplayMessage) ' 0 = all records, N = Max
: recordset size
:         .Parameters.Append .CreateParameter ("@EPID", adInteger,
: adParamInputOutput, , 0) ' Set to zero to read the next recordset
:         Set objRS = .Execute 'Gets an ADO recordset of all the emails
:     End With
: 
: ... some other code here, then I want to execute objCmd again, with a
: different value for strDisplayMessage
: 
:             strDisplayMessage = "hello"
:             .Execute ,,adExecuteNoRecords ' Execute same command object
: with revised intEPID to record send duration statistics
: 
: Is there a .Parameters method to Update the value of @Message or do I
: need to destroy and recreate objCmd?
: 
: Sam


More information about the thelist mailing list