RE: Non initialized Cmd Parameter Collection via ASP vs SQL Server



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


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
that
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



.



Relevant Pages

  • RE: Non initialized Cmd Parameter Collection via ASP vs SQL Server 200
    ... component to access database and execute some stored procedure. ... error when change the database from SQL server 2000 to SQL Server 2005, ... Microsoft MSDN Online Support Lead ... Delighting our customers is our #1 priority. ...
    (microsoft.public.data.ado)
  • RE: Visual Basic 2005.Net TableAdapters
    ... TableAdapter doesn't work in the same manner as a SQL Server Stored ... A stored procedure consists of several SQL statements and compiled on the ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Assertion: SQL Server 2000 cant issue a SOAP call
    ... It might be worth mentioning that calling CLR code from SQL Server is not ... > from a stored procedure, or from an extended stored procedure, but I don't ... >> SOAP call from SQL Server 2000. ... >> PS - Also, I have called MSDN support, and I will let both groups know ...
    (microsoft.public.sqlserver.programming)
  • Re: Best database(different from the usual "profile")
    ... > The other issue is price and support. ... then you will get a lot of support hassle. ... > customers with a support dept you can give them the SQL Server option. ...
    (borland.public.delphi.thirdpartytools.general)
  • Re: Newbie: feature comparison
    ... SQL Server is not alone. ... DB2 also doesn't support Multi Version ... Triggers are usually _not_ the ideal solution in any situation, ... shouldn't use a stored procedure here I don't see. ...
    (microsoft.public.sqlserver.server)