Reputation: 7618
I have a stored procdure that works fine when i execute in sql server management console but when use in strongly typed dataset it always return "1" (i think that it means record is inserted).
Here's the SP
USE [DataBaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[InsertRecord]
(
@a int,
@b int
)
AS
INSERT Into tableName
Values
(
@a,
@b
)
return SCOPE_IDENTITY()
Now when i drag and drop the procedure on strongly typed dataset it gives me these options, before it was on "single value".
Upvotes: 2
Views: 86
Reputation: 18749
It might be that it's returning 1 for the inserted record due to not having SET NOCOUNT ON;
in the SP. Try adding this, it should solve the issue. Not having this will give you the amount of affected records, 1 in your case.
USE [DataBaseName]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[InsertRecord]
(
@a int,
@b int
)
AS
SET NOCOUNT ON;
INSERT Into tableName
Values
(
@a,
@b
)
return SCOPE_IDENTITY()
Upvotes: 1