Click here to Skip to main content
14,698,806 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C# with Linq data inserting confirmation, in ADO.Net we can return bool as a return type for confirmation if it is true, but how do we do that in LINQ with SQL Approach
BankDataContext obj = new BankDataContext();
   BankAccount obj1 = new BankAccount();
  obj1.accountid =1;
  obj1.balance = 560;
  obj1.bankname ="bkl";
  obj.BankAccounts.InsertOnSubmit(obj1);
  obj.SubmitChanges();
Posted
Updated 20-Mar-13 7:16am
v3

1 solution

Use Sql Out Parameters in stored procedure ...
for example


Quote:
CREATE PROCEDURE [dbo].[MY_SAMPLE_SP]
@PARAM1 NVARCHAR(15),
@PARAM2 BIGINT =NULL,
@PARAM3 NVARCHAR(50) =NULL,
@PARAM4 BIT =NULL,
@PARAM5 NVARCHAR(100) =NULL,
@PARAM6 BIGINT =NULL,
@PARAM7 INT =NULL,

@OPERACTION VARCHAR(10) =NULL,
@SUCCESS BIT OUT,
@ERRORNAME NVARCHAR(MAX) OUT
AS
BEGIN
IF UPPER(@OPERACTION) = 'INSERT'
BEGIN
BEGIN
BEGIN TRY
INSERT INTO [DBO].[PR_SRY_GROUP_MASTER]
(
[COLUMN1]
,[COLUMN2]
,[COLUMN3]
,[COLUMN4]
,COLUMN5
,[COLUMN6]
)
VALUES
(
@PARAM1
,@PARAM2
,@PARAM3
,@PARAM4
,@PARAM5
,@PARAM6
);

SET @SUCCESS=1
SET @ERRORNAME='SUCCESS'

END TRY
BEGIN CATCH
BEGIN
SET @SUCCESS=0
SET @ERRORNAME=ERROR_MESSAGE() + ' : ' + ERROR_NUMBER();
END
END CATCH

END
ELSE
BEGIN
SET @SUCCESS=0;
SET @ERRORNAME='ERROR' ;
END
END
END
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900