the stored procedure has been executed from isql successfully and returns proper value and @@rowcount correctly; SAConnection myConnection = ModuleDb.myConnection;

SACommand myCmd = new SACommand("dba.get_AcctInfo", myConnection);
myCmd.CommandType = System.Data.CommandType.StoredProcedure;

if (myConnection.State.CompareTo(ConnectionState.Broken) == 0 |
myConnection.State.CompareTo(ConnectionState.Closed) == 0)
myConnection.Open();

SAParameter parm1 = new SAParameter("@WebAcctShortName", SADbType.VarChar);
parm1.Precision = 0;
parm1.Scale = 0;
parm1.Size = 24;
parm1.Direction = ParameterDirection.Input;
parm1.IsNullable = false;
parm1.SourceColumnNullMapping = false;
parm1.Value = WebAcctShortName;
myCmd.Parameters.Add(parm1);

SAParameter parm2 = new SAParameter("@acct_ID", SADbType.Integer);
parm2.Precision = 0;
parm2.Scale = 0;
parm2.Size = 4;
parm2.Direction = ParameterDirection.Output;
parm2.IsNullable = false;
parm2.SourceColumnNullMapping = false;
myCmd.Parameters.Add(parm2);

SAParameter parm3 = new SAParameter("@AcctTyp", SADbType.VarChar);
parm3.Precision = 0;
parm3.Scale = 0;
parm3.Size = 1;
parm3.Direction = ParameterDirection.Output;
parm3.IsNullable = false;
parm3.SourceColumnNullMapping = false;
myCmd.Parameters.Add(parm3);
...
object o = myCmd.ExecuteScalar();// I got null here, why?
/*
    however in isql
begin
declare rc int;
declare @WebAcctShortName varchar(24);
declare @coCode varchar(10);
declare @acct_ID integer;
declare @AcctTyp varchar(1);
declare @acctGrpId integer;
declare @acct_alias varchar(16);
declare @acctNicknm varchar(28);
set "@webAcctNbr" = '68622424'; set"@WebAcctShortName" = 'INVEST';
set"@coCode" = null;
rc= CALL "dba"."get_AcctInfo" ("@webAcctNbr","@WebAcctShortName","@coCode", @acct_ID,
 @AcctTyp, @acctGrpId,@acct_alias, @acctNicknm);// into rc;
select rc, @acct_ID, @AcctTyp, @acctGrpId,@acct_alias, @acctNicknm;
end
yield all proper values
what did I go wrong in my C# code?
the c# app is .net 3.5, from visual studio 2008 standard
actually the code was generated from a template that I was able to use successfully many times.
*/

asked 16 Aug '13, 01:17

gg99's gravatar image

gg99
227293038
accept rate: 10%

edited 16 Aug '13, 01:24

How do you specify the parameter for the SP's return value (i.e. the parameter that will hold what the variable rc receives in the DBISQL call)?

(20 Aug '13, 04:20) Volker Barth

Try select from dba.get_AcctInfo instead of call dba.get_AcctInfo

permanent link

answered 19 Aug '13, 05:07

Martin's gravatar image

Martin
9.0k130169257
accept rate: 14%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×76
×34
×9

question asked: 16 Aug '13, 01:17

question was seen: 2,887 times

last updated: 20 Aug '13, 04:20