This is my stored procedure
Create PROCEDURE dbo.veriftest
@valueGuid varchar(50),
@message int Output
AS
Begin
DECLARE @SelectValue varchar(50)
select @SelectValue = code FROM test WHERE code=@valueGuid;
If @valueGuid=@SelectValue
BEGIN
DELETE code FROM test WHERE code=@valueGuid ;
SET @message = 0
END
Else
BEGIN
Set @message = 1
END
END
This the vb Code
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim connectionString As String = WebConfigurationManager.ConnectionStrings("BecsEtMuseauxSQL").ConnectionString
Dim con As SqlConnection = New SqlConnection(connectionString)
Dim cmd As New SqlCommand("veriftest", con)
cmd.CommandType = CommandType.StoredProcedure
Dim objParameter As New SqlParameter("@valueGuid", SqlDbType.NVarChar, 15)
cmd.Parameters.Add(objParameter)
objParameter.Direction = ParameterDirection.Input
objParameter.Value = TextBox1.Text
Dim returnvalue As New SqlParameter("@message", SqlDbType.Int, 0)
returnvalue.Direction = ParameterDirection.Output
cmd.Parameters.Add(returnvalue)
con.Open()
cmd.ExecuteNonQuery()
Dim count As Integer = Int32.Parse(cmd.Parameters("@message").Value.ToString())
Label1.Text = count
con.Close()
End Sub
I get trouble when the stored procedure is execute (cmd.ExecuteNonQuery()) That said the object name code is not valid....
I really don't understand I just want to catch the output @messase in my label1......
This id in vb.net
Thanks
Frank
You need to change your delete statement in the stored proc to:
DELETE FROM test WHERE code=@valueGuid
You can also make your stored proc much more efficient:
Create PROCEDURE dbo.veriftest
@valueGuid varchar(50),
@message int Output
AS
Begin
DELETE code FROM test WHERE code=@valueGuid
SET @message = @@ROWCOUNT
END
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.