Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ADO to call IBM Program that accepts and returns parm

Status
Not open for further replies.

Lerb

Programmer
Dec 14, 2005
4
US
I am attempting to call a program from DB2 that accepts and returns a parm (AMSG). Very simple proof of concept (I am very new to both IBM and ADO)... the program should simply accept a character message and should return the same. I cannot for life of me figure out how to display the message I sent. Here is my code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE> ADO Example 5 ... connection to as400 </TITLE></HEAD>
<BODY>
<!-- #include FILE="adovbs.inc" -->
<H1> HELLO WORLD!</H1>
<%
' set connection and recordset objects.
Dim adoCon
Dim adoRec
Set adoCon = Server.CreateObject("ADODB.Connection")
Set adoRec = Server.CreateObject("ADODB.Recordset")
Set adoCmd = Server.CreateObject("ADODB.Command")
strConn = "Provider=IBMDA400;User ID=AAAA;Password=AA;Data Source=PRIVATE;"
adoCon.Open strConn

adoCmd.CommandText = "CALL MARSTEST('YO')"
adoCmd.CommandType = adCmdText
set objParm = adoCmd.CreateParameter("AMSG",129,3,5)
adoCmd.Parameters.Append(objParm)
adoCmd.Parameters("AMSG") = "YOYO!"
set adoCmd.ActiveConnection = adoCon

Set adoRec = adoCmd.Execute
%>

<%
Set adoRec = Nothing
Set adoCon = Nothing
Response.Write("<br>HELLO!.")
%>
</BODY>
</HTML>

This code runs without error, but if I try to do a response.write or <%=whatever%> (i.e. Response.Write(adoRec.field(1).value), I get errors.
How do I expose the message ("YO", or "YOYO")?
 
HELLO? Anyone? I really need some help here!
 
Do you know that it is returning a recordset? I don't work with DB2, but suspect it is only returning the parameter not a recordset.

Check.
adoRec.State
to see if there is an open recordset. I believe it returns a 1 if open - check your documentation.

A parameter is usually returned right on the connection or command and this is relative to zero.
adoCon(0)
or
adoCmd(0)

This should be
adoRec.fields(0).value
if a recordset is returned.




 
Thank you for replying. I'm afraid I'm still confused. I added a check like you suggested:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD><TITLE> ADO Example 5 ... connection to as400 </TITLE></HEAD>
<BODY>
<!-- #include FILE="adovbs.inc" -->
<H1> HELLO WORLD!</H1>
<%
' set connection and recordset objects.
Dim adoCon
Dim adoRec
Set adoCon = Server.CreateObject("ADODB.Connection")
Set adoRec = Server.CreateObject("ADODB.Recordset")
Set adoCmd = Server.CreateObject("ADODB.Command")
strConn = "Provider=IBMDA400;User ID=xx;Password=x;Data Source=xxxx;"
adoCon.Open strConn

adoCmd.CommandText = "CALL MARSTEST('YO')"
adoCmd.CommandType = adCmdText
set objParm = adoCmd.CreateParameter("AMSG",129,3,5)
adoCmd.Parameters.Append(objParm)
adoCmd.Parameters("AMSG") = "YOYO!"

set adoCmd.ActiveConnection = adoCon
set adoRec = adoCmd.Execute
adoRec.State
%>

<%
Set adoRec = Nothing
Set adoCon = Nothing
Response.Write("<br>HELLO!.")
%>
</BODY>
</HTML>

But when I attempted to run the code in the browser, I got this error:

Wrong number of arguments or invalid property assignment: 'State'

And just for clarification, this is a super simple program that is being called... no SQL involved... I just pass in a parameter and want that same parameter to be passed back and exposed.
 

Try doing a Response.Write on adoCmd(0)


I don't think you are getting a recordset returned. The parameter should be returned in the first position on the command object.
 
Thank you! The output looks like this:

HELLO WORLD!
YOYO!
HELLO!.

That gets me one little stpe further towards my goal. Appreciate your help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top