[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

as/400 and odbc calls to an rpg program... [odbc.net]

Josh Patterson

9/23/2002 5:37:00 PM

Guys,
I am working on converting some old com+ dlls to .NET managed objects,
possibly even web services if im feeling frisky. Under the client access
driver and vb, I wrote a com+ dll that called a rpg program on the 400 and
returned parameters via the command object parameters [in/out]:

Old code, in vb6:

Dim Conn As ADODB.Connection
Set Conn = New ADODB.Connection

Dim Comm As ADODB.Command
Set Comm = New ADODB.Command

Conn.Open "Provider=IBMDA400;Data Source=***.***.***.***;", "*****",
"*****" '// rem'd out for fun

Comm.ActiveConnection = Conn
Comm.CommandText = "{{CALL
/QSYS.LIB/XPSOBJ.LIB/MCMKSNRU.PGM(?,?,?,?)}}"
Comm.CommandType = adCmdUnknown
Comm.Prepared = True

Set Parm1 = Comm.CreateParameter("GMH", adChar, adParamInput, 9)
Set Parm2 = Comm.CreateParameter("Mailbox", adChar,
adParamInput, 10)
Set Parm3 = Comm.CreateParameter("FunneledMessageResponse",
adChar, adParamInput, 1)
Set Parm4 = Comm.CreateParameter("ReturnStatus", adChar,
adParamReturnValue, 1)

Comm.Parameters.Append Parm1
Comm.Parameters.Append Parm2
Comm.Parameters.Append Parm3
Comm.Parameters.Append Parm4

Dim Parms

Parms = Array(strMessage_GMH, strMailboxName,
strFunnledMessageResponse, strBlank1)

Comm.Execute Rcds, Parms, adCmdText

iReturnValue = CInt(Comm.Parameters("ReturnStatus"))

now this worked great. It called the program and returned the parameters we
requested. However, I began my journey to convert this to .NET and, here is
where I am:

[In vc.NET]
this->pOdbcConn = new OdbcConnection();

// passwords and usernames rem'd out

this->pOdbcConn->ConnectionString = S"DRIVER={Client Access ODBC Driver
(32-bit)};SYSTEM=192.168.40.3;CMT=3;NAM=0;DFT=5;DSP=1;TFT=0;TSP=0;DEC=0;XDYN
AMIC=0;RECBLOCK=2;BLOCKSIZE=32;SCROLLABLE=0;TRANSLATE=0;LAZYCLOSE=1;LIBVIEW=
0;REMARKS=0;CONNTYPE=0;SORTTYPE=0;PREFETCH=0;DFTPKGLIB=XPSFILE;LANGUAGEID=EN
U;SORTWEIGHT=0;MAXFIELDLEN=32;COMPRESSION=0;ALLOWUNSCHAR=0;SEARCHPATTERN=0;M
GDSN=0;UID=******;PWD=******;";

this->pOdbcConn->Open();

OdbcCommand *pCommand = new OdbcCommand();

pCommand->Connection = this->pOdbcConn;

pCommand->CommandType = CommandType::StoredProcedure;

// pCommand->CommandText = S"{{CALL
/QSYS.LIB/XPSOBJ.LIB/MCMKSNRU.PGM(?,?,?,?)}}"; old way, doesnt seem to
like the extra verbage

pCommand->CommandText = S"CALL XPSOBJ.MCMKSNRU(?,?,?,?)";

//pCommand->CommandText = S"CALL XPSOBJ.MCMKSNRU('571732539','ELITE ',' ','
')"; // this works with the params hardcoded in

OdbcParameter *pParam0 = new OdbcParameter( S"GMH",
Microsoft::Data::Odbc::OdbcType::Char, 9 );

pParam0->set_Direction( System::Data::ParameterDirection::InputOutput );

OdbcParameter *pParam1 = new OdbcParameter( S"Mailbox",
Microsoft::Data::Odbc::OdbcType::Char, 10 );

pParam1->set_Direction( System::Data::ParameterDirection::InputOutput );

OdbcParameter *pParam2 = new OdbcParameter( S"FunneledMessageResponse",
Microsoft::Data::Odbc::OdbcType::Char, 1 );

pParam2->set_Direction( System::Data::ParameterDirection::InputOutput );

OdbcParameter *pParam3 = new OdbcParameter( S"ReturnStatus",
Microsoft::Data::Odbc::OdbcType::Char, 1 );

pParam3->set_Direction( System::Data::ParameterDirection::InputOutput );

pCommand->Parameters->Add( pParam0 );

pCommand->Parameters->Add( pParam1 );

pCommand->Parameters->Add( pParam2 );

pCommand->Parameters->Add( pParam3 );

//pCommand->Prepare();

pCommand->ExecuteNonQuery();


now, I get an error like:

[IBM][Client Access Express ODBC Driver (32-bit)][DB2/400 SQL]SQL0204 -
MCMKSNRU in XPSOBJ type *N not found

Native Error: -204
Source: CWBODBC.DLL
SQL State: 42502

Ive tried changing the param types in the command object, I've tried to
change various command object properties, I've tried to change the
commandText rpg call text layout, Ive tried to set the Prepared() method on
the command object --- nothing works when I try to send in the ? param
placeholders and get values back. It always seems to send that "type *N not
found " error back.

help.

Thanks!

Josh Patterson