存储过程参数问题
我在SQL2000中写拉存储过程:
CREATE PROCEDURE EditText
@Caption nvarchar(50),
@ID int
AS
UPDATE [Text]
SET [Caption] = @Caption
WHERE [ID]= @ID
RETURN
GO
下面传递参数
Public Shared Sub EditText(ByVal Caption As String, ByVal ID As Integer)
Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings( "Personal ").ConnectionString)
Using command As New SqlCommand( "EditText ", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(New SqlParameter( "@Caption ", Caption))
command.Parameters.Add(New SqlParameter( "@ID ", ID))
connection.Open()
command.ExecuteNonQuery()
End Using
End Using
End Sub
但当Caption的参数为空时却出现出误:
过程 'EditText ' 需要参数 '@Caption ',但未提供该参数
有什么办法解决吗?请各位大哥帮助! 一只迷途的羔羊
[解决办法]
CREATE PROCEDURE EditText
@Caption nvarchar(50)= ' ',
@ID int
AS
UPDATE [Text]
SET [Caption] = @Caption
WHERE [ID]= @ID
RETURN
GO
给个默认值