Click here to Skip to main content
15,881,701 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
i need output for sql print value i am passing some values how to get that value aspx page any one help me sir
Posted
Comments
Guirec 3-Oct-12 8:40am    
If I understand correctly you have some sql which makes usage of the "print" function and you want to get the output string appearing on a web page. Right?
if Yes then there is no direct way. You have to modify the sql so that you create a variable which is the concatenation of what you are printing and then use that variable as an output command of your ado.net query.

1 solution

If you are trying to return a variable from your Stored Procedure, then you must declare an output variable. A sample Procedure is shown below.
You can then get the variable in your aspx page accordingly. Dont forget to handle null.
SQL
CREATE PROCEDURE [dbo].[sample]
     @input varchar,
     @output varchar OutPUT
AS
SET NOCOUNT ON

BEGIN
  IF @input = 1  
   BEGIN
    SET @output ='your message'
   END
END

OR

If you were referring to print an error message from the SQL stored Proc , then use RAISEERROR function in your SQL Procedure.
use link http://msdn.microsoft.com/en-us/library/ms178592.aspx[^]

You can then catch the exception in the aspx page and display it as required.
 
Share this answer
 
v3
Comments
Oshtri Deka 4-Oct-12 11:20am    
Comprehensive.
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900