× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



did you use ODBC administration on the Windows PC? The user DSN name
setup there is then specified as the DSN= in the connection string.

static OdbcConnection OpenConnection(string Dsn, string UserName,
string Password)
{
var connString = "DSN=" + Dsn + "; UID=" + UserName +
"; PWD=" + Password + ";";
var conn = new OdbcConnection(connString);
conn.Open();
return conn;
}

-Steve




On Fri, Mar 6, 2015 at 12:52 AM, Guo, Fuwang <fg33@xxxxxxxx> wrote:

I have a stored procedure created on the AS400 that takes in 2 parameters
and returns either 000 if found and 001 if not found. I don't think I have
the correct syntax for the commandtext. The following passes ?0 and 00 to
the AS400. When I watch commandtext at the prepared statement it still
shows ? and ?. Not sure if it normally fills it in.

I can hardcode the parameters "CALL DKDEXE.DKSLICCHK1 ('AAAAAA1','*43
spaces*')" and the AS400 gets the correct data and returns a valid 001 but
I can not get that 001 back to my program. I'm out of ideas as to how to
call the store procedure and get the return code. What is wrong with my
code?

using (OdbcConnection cn = new OdbcConnection("Driver=Client Access
ODBC Driver (32-bit);System=X;Uid=U;Pwd=P"))

{

cn.Open();

using (OdbcCommand cm = cn.CreateCommand())

{

cm.CommandText = "CALL DKDEXE.DKSLI ('?','?')";

cm.CommandType = CommandType.StoredProcedure;

cm.Parameters.Add("P1", OdbcType.Char).Value =
"AAAAAAA1";

cm.Parameters["P1"].Size = 8;

cm.Parameters["P1"].Direction =
ParameterDirection.Input;


cm.Parameters.Add("P2", OdbcType.Char);

cm.Parameters["P2"].Size = 43;

cm.Parameters["P2"].Direction =
ParameterDirection.InputOutput;

cm.Prepare();

cm.ExecuteNonQuery();

string result =
cm.Parameters["P2"].Value.ToString();

}


I also tried {CALL DKDEXE.DKSLICCHK1 (?,?)} but I get an error ERROR
[42S02] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 - DKSLI in
DKDEXE type *N not found.

Thanks
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.