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



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 2008 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
    ... 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: How to get list of EventClasses in MSSQLServer2000
    ... statement inside a stored procedure has completed.') ... SQL Server statement or stored procedure.') ... Plan','Displays the plan tree of the Transact-SQL statement executed.') ... Login','Occurs when a SQL Server login is added or removed; ...
    (microsoft.public.sqlserver.security)
  • 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: Accessing FoxPro Free Table
    ... which the SQL Server service is running. ... account, ... > If you are creating a stored procedure and you want> to make sure that the procedure definition cannot be> viewed by other users, you can use the WITH ENCRYPTION> clause. ... The procedure definition is then stored in an> unreadable form. ...
    (microsoft.public.data.odbc)
  • Stored procedure does not complete until result set is retrieved from ODBC
    ... I have a SQL Server Stored procedure that I am executing via ODBC. ... -- Start Code without cursor ...
    (microsoft.public.sqlserver.odbc)