RE: Non initialized Cmd Parameter Collection via ASP vs SQL Server
- From: Lars-Erik <lars-erik@xxxxxxxxxxxxxxxx>
- Date: Wed, 14 May 2021 04:14:00 -0700
Hi!
The code I provided doesn't show, but after the connection, command type and
command text are set I also call
oCmd.Parameters.Refresh
I've done a little testing at the customers server, and it seems that
Refresh fills the parameters for some, but not all of the stored procedures.
Any way to fix it?
--
Lars-Erik
"Steven Cheng [MSFT]" wrote:
Hi LE,.
From your description, you have an classic ASP program which will use ADO
component to access database and execute some stored procedure. The
application runs well originally, but raised some "parameter index...."
error when change the database from SQL server 2000 to SQL Server 2005,
correct?
Based on the code you provided, you use a loop to add parameters into ADO
command object via index. I would suggest you use ADOCommand.Create
Parameter and Append method to create the parameters and append them into
Parameters collection. Here is a kb article demonstrate this:
#How to run SQL Server stored procedures from an ASP Page
http://support.microsoft.com/kb/300488
you can try the code style in it to see whether it works. Also, you can try
calling some other simple stored procedure s to see whether the problem is
specific to a particular stored procedure.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?TGFycy1Fcmlr?= <lars-erik@xxxxxxxxxxxxxxxx>
Subject: Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
Date: Tue, 13 May 2021 01:41:01 -0700
that
Hi!
I have some ancient VBScript code running in ASP 3.0. In our development
area the code runs well, but at our customers server it fails claiming
the parameter collection is not initialized. (IE. index out of range);)
The stuff has run fine on SQL Server 2000 before, but the customer has
upgraded to SQL Server 2005.
They haven't upgraded to SP 1 or 2 yet, but I'm not entirely sure that is
the reason.
Any other possible reasons why the following code won't pre-populate the
parameters collection with return value and one input parameter?
(I use storedproc = 4, "myProcedureName", "myConnection", Array(string) as
parameters here)
Of course it fails on Set oRetPm = oCmd.Parameters(0) since I have handled
the following statements. And the procedure has both return and parameter.
function runCommand(nCommandType, sCommandText, vConn, aParameters, byref
vRetVal)
dim oCmd
dim oRetPm
dim i
runCommand = false
Set oCmd = Server.CreateObject("ADODB.Command")
if isObject(vConn) then
Set oCmd.ActiveConnection = vConn
else
oCmd.ActiveConnection = vConn
end if
oCmd.CommandType = nCommandType
oCmd.CommandText = sCommandText
Set oRetPm = oCmd.Parameters(0)
if isArrayInited(aParameters) then
for i = 0 to ubound(aParameters)
Response.Write "<!-- " & oCmd.Parameters(i + 1).Name & " : " &
aParameters(i) & " -->" & vbCrLf
on error resume next
oCmd.Parameters(i + 1).Value = aParameters(i)
if Err.number <> 0 then
Response.Write "<!-- " & Err.description & " -->"
Set oCmd = nothing
runCommand = false
exit function
end if
on error goto 0
next
end if
--
Lars-Erik
- Follow-Ups:
- Re: Non initialized Cmd Parameter Collection via ASP vs SQL Server
- From: Bob Barrows [MVP]
- Re: Non initialized Cmd Parameter Collection via ASP vs SQL Server
- References:
- Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
- From: Lars-Erik
- RE: Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
- From: Steven Cheng [MSFT]
- Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
- Prev by Date: Re: Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
- Next by Date: Re: Non initialized Cmd Parameter Collection via ASP vs SQL Server
- Previous by thread: Re: Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
- Next by thread: Re: Non initialized Cmd Parameter Collection via ASP vs SQL Server
- Index(es):
Relevant Pages
|