Re: Cannot add the data into the table
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 12 Jan 2007 23:29:13 +0100
On Wed, 10 Jan 2007 14:29:00 -0800, BMW wrote:
There is my code of vb.net and SQL stored procedure
(snip)
Dim par2 As New SqlParameter("@RowCount",
SqlDbType.Int)
par2.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(par2)
Hi BMW,
You are defining a third (output) parameter here, ...
(snip)
Create PROCEDURE [dbo].[spDataTest]
-- Add the parameters for the stored procedure here
@Subject varchar(50),
@Result nvarchar(100)
.... but the stored procedure has only two parameters, ...
(snip)
return @@rowcount
.... and the rowcount is returned as a return value, not as an output
parameter.
You can fix this by changing the stored procedure as follows:
CREATE PROCEDURE dbo.spDataTest
@Subject varchar(50),
@Result nvarchar(100),
@RowCount int OUTPUT
AS
SET NOCOUNT ON;
INSERT INTO dbo.Result (Subject, Result)
VALUES (@Subject, @Result);
SET @RowCount = @@ROWCOUNT;
--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
.
- References:
- Re: Cannot add the data into the table
- From: Jens
- Re: Cannot add the data into the table
- From: BMW
- Re: Cannot add the data into the table
- Prev by Date: Re: Insert data
- Next by Date: Re: How to retieve previous rows based on query results
- Previous by thread: Re: Cannot add the data into the table
- Next by thread: Re: Insert data
- Index(es):
Relevant Pages
|
|