检查存储过程中的记录插入是否成功? [英] Check whether record insertion is successful in stored procedure ?

查看:71
本文介绍了检查存储过程中的记录插入是否成功?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在插入存储过程中,我想验证记录插入是否成功....喜欢



创建存储过程{

...



if( flg == 0)

{

插入成功

}

else if(flg == 1)

{

插入失败

}

...

}



注意:表中没有标识列。

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.

推荐答案

当您通过ExecuteNonQuery()方法插入Dada时。这个方法返回受数据库影响的查询号作为整数数据类型..

所以请你减少你的问题。



For示例。



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.

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







谢谢

AARIF SHAIKH




Thanks
AARIF SHAIKH


这篇关于检查存储过程中的记录插入是否成功?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆