Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Return SQL Mesaage to web or anywhere possible?

Author  Topic 

besadmin
Posting Yak Master

116 Posts

Posted - 2009-02-22 : 00:21:02
if you do an IF statement that returns a variable like 'success' or 'failure' it returns it in the SQL Message pane - the same place it says '10 row(s) affected' - is it possible to do anything with the info returned there? my goal is return it to a web page. Any help is greatly appreciated.

Thanks a ton!!

S

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-22 : 01:34:57
yup. you can return the message to webpage by using an output varchar parameter in your procedure and returning value through. then use a variable in your front end to receive this and display in your page

http://support.microsoft.com/kb/320916
Go to Top of Page

besadmin
Posting Yak Master

116 Posts

Posted - 2009-02-22 : 01:58:44
sweet!
Thanks a ton V - I will try it out and let you know how it flows.

Thanks again!!

-S
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-22 : 02:03:24
welcome
Go to Top of Page

besadmin
Posting Yak Master

116 Posts

Posted - 2009-02-22 : 03:14:23
wow, awsome example, i totally get it now.

Thanks a ton v!

This will really help me!!

later!
Go to Top of Page

besadmin
Posting Yak Master

116 Posts

Posted - 2009-02-24 : 14:18:19
Hey friends, I still need a little more help with this?
IF i do this

EXEC Stored Procedure
IF @Stat = 0
BEGIN
PRINT 'Success'
END
ELSE
BEGIN
PRINT 'Failure'
END


How can i return the Success or Failure 'print' message back to the web page?
THanks so much for any help!
Go to Top of Page

besadmin
Posting Yak Master

116 Posts

Posted - 2009-02-24 : 15:49:21
or how can i use a return or output to return success of failure?
So i can return success or failure back to my webpage?
Please help friends!!
Thanks a ton!
Go to Top of Page

sakets_2000
Master Smack Fu Yak Hacker

1472 Posts

Posted - 2009-02-25 : 10:34:25
You can alter your procedure for error handling. Look at this, sample picked up from BOL.

CREATE PROCEDURE add_author 
@au_id varchar(11),@au_lname varchar(40),
@au_fname varchar(20),@phone char(12),
@address varchar(40) = NULL,@city varchar(20) = NULL,
@state char(2) = NULL,@zip char(5) = NULL,
@contract bit = NULL
AS

-- Execute the INSERT statement.
INSERT INTO authors
(au_id, au_lname, au_fname, phone, address,
city, state, zip, contract) values
(@au_id,@au_lname,@au_fname,@phone,@address,
@city,@state,@zip,@contract)

-- Test the error value.
IF @@ERROR <> 0
BEGIN
-- Return 99 to the calling program to indicate failure.
PRINT "An error occurred loading the new author information"
RETURN(99)
END
ELSE
BEGIN
-- Return 0 to the calling program to indicate success.
PRINT "The new author information has been loaded"
RETURN(0)
END
GO
Go to Top of Page

besadmin
Posting Yak Master

116 Posts

Posted - 2009-03-02 : 09:59:33
Hey sakets_2000
thanks a ton for the reply, i will def play with that example some! The only thing i guess i am confused about just by looking at that example is how to call the '0' or '99' from the web page, or return those values to the web page. where are they stored? I should look at using return values correct? and how to use with asp.net c# right?

I will play with it some more and let you know whats up.

thansk again for the reply!!

Later,

-S
Go to Top of Page
   

- Advertisement -