Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In insert stored procedure i want to verify whether record insertion is successful....i.e. like

Create stored procedure{
...

if(flg==0)
{
insert successful
}
else if (flg==1)
{
insert failed
}
...
}

Note: No identity column is there in table.
Posted

1 solution

When you Insert Dada through ExecuteNonQuery() Method .. This method Return No. of Query Affected in Database as integer datatype..
So please you it for reducing your problem.

For Example.

C#
int i=0;
i= cmd.ExecuteNonQuery();
if( i >0)
 {
  msg ="Inserted Successfully";
 }
else
  msg="Not Inserted";



Thanks
AARIF SHAIKH
 
Share this answer
 
Comments
Shweta N Mishra 20-Nov-14 4:04am    
+5

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