return values from stored procs

Results 1 to 2 of 2

Thread: return values from stored procs

  1. #1
    Join Date
    Dec 1969

    Default return values from stored procs

    can anyone pl. tell me how to use return values of SPs in VB ? <BR>i&#039;m doing this in VB <BR><BR> Dim irtnval As Integer<BR> Dim strsql As String<BR> <BR>mObjConn1.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=OMS_P0070;Data Source=DEV_SERVER"<BR> <BR> strsql = " execute @irtnval = spu_tempo "<BR> <BR> irtnval = mObjConn1.Execute(strsql)<BR> if irtnval = 22 then <BR> &#039; blah bla<BR> else <BR> end if <BR><BR>but this is not working . please help . basically wanted to check for 22 or 33 as that&#039;s what i expect SP to return !<BR><BR>as of with this code it gives TypeMismatch compile error in VB on irtnval = mObjConn1.Execute(strsql). <BR><BR>my SP code is ==&#062;<BR><BR>creare sp1 AS <BR><BR>DECLARE @errnosp AS INTEGER<BR><BR>SELECT ProductLevel FROM tblTankData WHERE TankNumber= 1<BR><BR>set @errnosp = @@error <BR><BR>if @errnosp &#060;&#062; 0 <BR> begin <BR> print " error from sp" <BR> return 22<BR> end <BR>else <BR> begin <BR> print " no error from sp" <BR> return 33<BR> end <BR><BR><BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: return values from stored procs

    CREATE SP1 <BR>@errnosp int OUPUT<BR><BR>AS<BR><BR>set @errnosp = @@error <BR><BR>if @errnosp &#060;&#062; 0 <BR>begin <BR>print " error from sp" <BR>return @errnosp <BR>end <BR>else <BR>begin <BR>print " no error from sp" <BR>return @errnosp <BR>end <BR><BR>page.asp:<BR><BR>Connection.Execute("exe c SP1 " & varToHoldTheReturnValue)<BR><BR>Response.write varToHoldTheReturnValue<BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts