0
SqlParameter[] par1 = new SqlParameter[4];

par1[0] = new SqlParameter("@prefix", "TIN-CMP-");
par1[1] = new SqlParameter("@codeLength", "17");
par1[2] = new SqlParameter("@LastCode", "");
par1[3] = new SqlParameter("@retVal", SqlDbType.VarChar, 20);
par1[3].Direction = ParameterDirection.Output;
var data = SqlHelper.ExecuteNonQuery(this.ConnectionString, "Proc_GenerateID", par1);

it doesn't throw any exception but returns null value, Even procedure working fine in SSMS

Mox Shah
  • 2,967
  • 2
  • 26
  • 42

1 Answers1

1

Make sure SqlHelper.ExecuteQuery is reading the output parameter value after executing the sproc.

e.g.

yourCommand.ExecuteNonQuery();
string retVal = yourCommand.Parameters["@retVal"].Value;
AdaTheDev
  • 142,592
  • 28
  • 206
  • 200
  • yes, I have checked its value at the time of debug, but its showing null – Mox Shah Mar 27 '12 at 09:51
  • Can you check what SQL is being executed via SQL Profiler, and then manually run that in SSMS, just to validate everything is as you would expect. If all looks OK, may need to see more code in SqlHelper.ExecuteNonQuery / sproc definition – AdaTheDev Mar 27 '12 at 10:02