存储过程中返回字符串
小弟在存储过程中,要实现返回字符串时出现问题,特来请教!
VB程序中的代码如下:
dim strMessage as string= " "
Dim dbCheckPalmInfo As New ClsPalmDatabase
Dim cmmCheckPalmInfo As SqlClient.SqlCommand
dbCheckPalmInfo.Open()
Dim sp_Message As SqlClient.SqlParameter
cmmCheckPalmInfo = New SqlClient.SqlCommand( "ups_CountMaterialVolume ", dbCheckPalmInfo.sqlConn)
cmmCheckPalmInfo.CommandType = CommandType.StoredProcedure
sp_Message = cmmCheckPalmInfo.Parameters.Add( "@strMessage ", SqlDbType.NVarChar, 255)
sp_Message.Direction = ParameterDirection.Output
cmmCheckPalmInfo.ExecuteNonQuery()
strMessage = cmmCheckPalmInfo.Parameters( "@strMessage ").Value.ToString
存储过程代码如下:
CREATE PROCEDURE dbo.ups_CountMaterialVolume
(
@strMessage varchar(255) output
)
AS
set @strMessage= 'sadfsdafas '
return (@strMessage))
GO
运行到VB代码的
strMessage = cmmCheckPalmInfo.Parameters( "@strMessage ").Value.ToString
时出现:
"将varchar 值 'sadfsdafas ' 转换为int 的列时发生语法错误. "
该如何解决啊???
[解决办法]
return (@strMessage))
这个代码去掉就可以了