2011-03-07 48 views
0

我写了一个商店程序。我不知道如何从商店程序获得打印信息

CREATE PROCEDURE [dbo].[Test] 
     (@Num int) 
AS 
BEGIN 
    IF @Num = 1 
     PRINT 'This is One'; 
    ELSE 
     PRINT 'This is Another'; 
END 

我在.NET

Dim SqlCmd as new sqlcommand 
DIm SqlCon as new sqlconnection 

sqlcon.connectionstring ="" 
sqlCmd.connection =con 
sqlcon.open() 
sqlcmd.commandtext ="Test" 
Sqlcmd.commandtype = commandtype.storeprocedure 

实现我不知道如何从存储过程打印消息 请帮助我。

+0

可能的重复。 http://stackoverflow.com/questions/299797/retrieving-output-messages-from-batch-sql-command-sql-server – 2011-03-07 07:57:42

回答

0

您需要使用SELECT语句或RETURN

0

PRINT是用来打印在控制台上的消息进行调试,你不能把它作为一个SP结果,而你应该使用输出变量这一点。

相关问题