473,396 Members | 1,966 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Struggling with db2 and my asp application -- Calling a stored procedure

Hi Guys

I have an ASP application that connects to an Oracle database, right now I'm trying to connect this same ASP application to a DB2 database (Express-C, version 9.5.0).

I'm in the process of trying to translate all the programing withing asp pages, so, can interact smoothly with db2.

Now, I have problems trying to use a stored procedure (db2) and call it from my asp application.

Here's part of my procedure:
Expand|Select|Wrap|Line Numbers
  1. CREATE PROCEDURE Y
  2.     (IN P1 VARCHAR(10), IN P2 SMALLINT, IN P3 DATE, OUT P4 CHAR)
  3.  
Here's my asp page:

Expand|Select|Wrap|Line Numbers
  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
  2. <%
  3. 'Establish the connection
  4. 'strConn = "DSN=mgs;UID=db2admin;PASSWORD=xxx"
  5. strConn = "Provider=IBMDADB2.DB2COPY1; DSN=mgs; UID=MARIO GONZALEZ; PWD=marito"
  6. Set Conn=Server.CreateObject("ADODB.Connection")
  7. Conn.Open strConn
  8.  
  9. 'Define the command object
  10. Set Cmd=Server.CreateObject("ADODB.Command")
  11. Cmd.ActiveConnection = Conn
  12. Cmd.CommandText = "CALL Y"
  13. Cmd.CommandType = 1
  14. Cmd.Parameters.Refresh
  15. Cmd.Properties.Refresh
  16.  
  17. 'Create and append the parameters
  18. Cmd.Parameters.Append Cmd.CreateParameter("P1",200,1,10)
  19. Cmd.Parameters.Append Cmd.CreateParameter("P2",2,1,0)
  20. Cmd.Parameters.Append Cmd.CreateParameter("P3",133,1,0)
  21.  
  22. 'Set the parameter values
  23. Cmd("P1")="A"
  24. Cmd("P2")=1
  25. Cmd("P3")="01/01/2005"
  26.  
  27. Cmd.Parameters.Append Cmd.CreateParameter("P4",200,2,1)
  28.  
  29. 'Execute the "CALL" statement for the procedure. ADO 'constructs the CALL statement
  30. set rs1=Cmd.Execute
  31.  
  32. 'Free the recordset
  33. set rs1=nothing
  34.  
  35. 'Display the results
  36. response.write "<HTML>"
  37. response.write cmd(1)
  38. response.write "<BR>"
  39. response.write cmd(2)
  40. response.write "</HTML>"
  41.  
  42. 'Close the connection
  43. Conn.Close
  44. set Conn=nothing
  45. %>
And here's the error on IE:

Error Type:
IBM OLE DB Provider for DB2 (0x80004005)
[DB2/NT] SQL0440N No authorized routine named "Y" of type "PROCEDURE" having compatible arguments was found. SQLSTATE=42884
/db2/test3.asp, line 30 (set rs1=Cmd.Execute)

Any thoughts?

Thanks
Jun 17 '09 #1
3 3722
jhardman
3,406 Expert 2GB
Welcome to Bytes.

I've never used db2, but your code looks good to me. Here are some basic troubleshooting questions I would try to answer if I was in your place:
Can you execute the stored proc from a different location, like a DB manager or query editor? do you get the expected results? Can you execute a static query ("SELECT max(lastUpdate) from tbl_currentOrders") using this connection that definitely goes to the right db?

If you answer yes to all of these, then you are probably listing the data types wrong. If you pull up a record set with the data fields you are interested in, you can list their data types as rs1("p1").dataType (I think that's right, but I'm typing from memory).

Let me know if this helps.

Jared
Jun 17 '09 #2
Hi Jared, thanks for replying.

I answered your questions below:

1) Can you execute the stored proc from a different location, like a DB manager or query editor? do you get the expected results?

A> Yes it runs smothly on Command Line Processor

2. Can you execute a static query ("SELECT max(lastUpdate) from tbl_currentOrders") using this connection that definitely goes to the right db?

A> Yes and also I can display the results on my asp page.

3. Datatypes

A> I tried with this property: Recordset1.Fields.Item("p1").Type, and these were the results:

PARAMETER NAME DATA-TYPE DIRECTION DATA-SIZE
P1 200 1 10
P2 2 1 0
P3 133 1 0
P4 200 2 1

Any thoyghts??

Mgsmario
Jun 18 '09 #3
jhardman
3,406 Expert 2GB
I had never used parameters.refresh, but I just looked it up. Check out this article, if you use the parameters.refresh, you don't need to use parameters.add. I think you have twice as many parameters as you need.

Let me know if this helps.

Jared
Jun 19 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: dw | last post by:
Hello all, I'm having a dickens of a time calling a stored procedure on a connection. Every time I do, it generates an error "Arguments are of the wrong type, are out of acceptable range, or are in...
4
by: Paul | last post by:
Hi, In SQL Books Online in the section on @@Error it gives the following example: -- Execute the INSERT statement. INSERT INTO authors (au_id, au_lname, au_fname, phone, address, city,...
1
by: Lauren Quantrell | last post by:
I'm using an Access2K front end on a SQL Server2K backend. I use Scope_Identity() in a lot of stored procedures to pass the newwly inserted record's unique ID to the next select statement in the...
1
by: Anthony Robinson | last post by:
I'm executing a stored procedure and getting the SQL0440N No authorized routine named "AMROBI2.CREATEAIMCONNECTION" of type "PROCEDURE " having compatible arguments was found. The schema...
10
by: Saso Zagoranski | last post by:
hi, this is not actually a C# problem but since this is the only newsgroup I follow I decided to post my question here (please tell me where to post this next time if you think this post...
2
by: Woody Splawn | last post by:
I am using SQL Server 2000 as the back-end. I have created a stored procedure in SQL server called usp_AddContract. This Stored procedure inserts a new contract into a contracts table. I have...
2
by: singlal | last post by:
Hi, my question was not getting any attention because it moved to 2nd page; so posting it again. Sorry for any inconvenience but I need to get it resolved fast. Need your help! ...
6
Soniad
by: Soniad | last post by:
Hello, I am excecuting a stored procedure in my ASP page , it has one out parameter (@confirm) . after executing the procedure i want to retreive this out parameter and assign it to variable...
0
by: mgsmario | last post by:
Hi Guys I have an ASP application that connects to an Oracle database, right now I'm trying to connect this same ASP application to a DB2 database (Express-C, version 9.5.0). I'm in the process...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.