locked
how do I retrieve the output parameter? RRS feed

  • Question

  • User1180617917 posted
    Hi, I know this is a pretty basic question, but I've just started using the Microsoft Data Access Application block, and I can't figure out how to access the value of an OUTPUT parameter. Here is my code: Dim strConn = HttpContext.Current.Application("strConn") SqlHelper.ExecuteNonQuery(strConn, CommandType.StoredProcedure, "AddJob", _ New SqlParameter("@AccountID", AccountID), _ New SqlParameter("@JobTitleEng", JobTitleEng), _ New SqlParameter("@JobID", JobID, ParameterDirection.Output)) How can I access the value of the JobID parameter so that I can store it in a variable? Thanks for your assistance,
    Wednesday, October 8, 2003 10:58 AM

All replies

  • User-1303368272 posted
    Since you are creating the parameters before passing them to the SQLHelper anyway, you can just assign the output one to a variable first, and then retrieve its value afterwards: Dim strConn = HttpContext.Current.Application("strConn") dim outputParameter as new SQLParameter("@JobID", JobID, ParameterDirection.Output) SqlHelper.ExecuteNonQuery(strConn, CommandType.StoredProcedure, "AddJob", _ New SqlParameter("@AccountID", AccountID), _ New SqlParameter("@JobTitleEng", JobTitleEng), _ outputParameter) 'Do something with outputParameter, e.g. response.write(outputParameter.value)
    Thursday, October 9, 2003 12:20 PM
  • User997210911 posted
    Is this possible ? does it works ? who can i get the output parameter SqlParameter [] arParms = new SqlParameter[2]; arParms[0] = new SqlParameter("@ID", SqlDbType.Int); arParms[0].Value = 1; arParms[1] = new SqlParameter("@returnFromSp", SqlDbType.TinyInt); arParms[1].Direction= ParameterDirection.Output; SqlHelper.ExecuteNonQuery(sqlConnstring,"doSomething",arParms); arParms[1].Value comes empty Thanks in advance
    Thursday, May 6, 2004 7:27 AM
  • User997210911 posted
    It's easy.... Just have to use the -->CommandType.StoredProcedure SqlHelper.ExecuteNonQuery(sqlConnstring , CommandType.StoredProcedure , "doSomething" , arParms); it works fine arParms[1].Value returns thw output from the SP
    Friday, May 7, 2004 6:11 AM