Solved

error '80004005'  when calling stored procedure with parameters using ADODB.Command

Posted on 2004-04-01
7
866 Views
Last Modified: 2008-02-07
Hello guys.
I'm trying to finish asp page that executes the sql server stored procedure. The database is SQL Server 2000.
Here is the piece that I'm trying to run:
*************************************************************************
    ' Call the stored procedure to populate usUser table
    Dim cn, cmd, param2, rs, sql, tmpXML
   
    Set cn = Server.CreateObject("ADODB.Connection")
    Set cmd = Server.CreateObject("ADODB.Command")
    Set param2 = Server.CreateObject("ADODB.Parameter")
    'Set rs = Server.CreateObject("ADODB.Recordset")
       
    cn.Open c_QBUS_MSSQL01Connection
    tmpXML = "<TEST1>"
   
    Set cmd.ActiveConnection = cn
    cmd.CommandText = "udp_insert_xml_usUser"
    cmd.CommandType = adCmdStoredProc
    Set param2 = cmd.CreateParameter("pXMLDoc",adLongVarchar,adParamInputOutput,10,tmpXML)
   
    cmd.Parameters.Append param2
    Response.Write("<p>Executing SQL stored procedure:" & cmd.CommandText)
       
    cmd.Execute

    'rs.Close
    cn.Close
    Set cn = Nothing
*************************************************************************

Stored procedure inserts contents of the variable into the table.

Wnenever I'm trying to run the page it returns the following error:
------------------------------------------------------------------------------------------------------------------
Executing SQL stored procedure:{ call udp_insert_xml_usUser(?) }

Provider error '80004005'

Unspecified error

/departments/it/UpShot/users.asp, line 157
--------------------------------------------------------------------------------------------------------------------
Where line 157 is the calling cmd.Execute method.

I noticed it only happens when I'm trying to call procedure with parameters. When I'm calling stored procedure without any parameters it executes fine.


What is wrong?

Any help will be highly appreciated.

Thanks,
Yuri.


0
Comment
Question by:yuri_legalmatch
  • 4
  • 3
7 Comments
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10738270
0
 

Author Comment

by:yuri_legalmatch
ID: 10738302
As I stated before - the problem occurs only if I'm calling stored procedure with parameters.

If I had this stored procedure without parameters it would run fine.

0
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 100 total points
ID: 10738349
Could you post your stored proc? Parameters must be added in the order in which they appear within stored proc. It seems your proc has only one parameter is that right.

Use the actual parameter name as the first parametr. Try with input, output paramters instead of one inputoutput paramter. Should work as inputoutput paramter, but splitting them will help to isolate the issue.
 
Set myParameter = Command.CreateParameter (Name, [Type], [Direction], [Size], [Value])

I am sure you may have seen these examples: I list them anyway.

http://support.microsoft.com/default.aspx?scid=kb;EN-US;300488

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q165/1/56.asp&NoWebContent=1
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:yuri_legalmatch
ID: 10738645
drop procedure udp_insert_xml_usUser
go

create procedure udp_insert_xml_usUser
                 (@pXMLDoc  text)
AS
  Declare
    @vReturnCode    int,
    @vDocID         int

select * from usUser

GO
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10740477
There is only one parameter. Try adParamInput.
regards-
0
 

Author Comment

by:yuri_legalmatch
ID: 10742525
I did change it it solved the problem....

Now I have different one. I'm passing ~26k characters of XML. Procedure blows somewhere. How should I trap the error?
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
ID: 10745356
Perform error checking ffter each statement

IF @@ERROR <> 0
Begin
  Raiserror(16001, 'Error inserting into mytable')
  Retrun 1000
End

Check the retrun number to see where the code blows. Or execute the procedure from query analyser with same parameter to track where the error is.

For debugging purposes PRINT statement can be used. But remove pront statements once finding where the issue is.

regards-

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now