如何使用Insert Command处理sqldatasource中的异常 [英] how to handling exception in sqldatasource using Insert Command

查看:96
本文介绍了如何使用Insert Command处理sqldatasource中的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:SqlDataSource ID="SqlDataSourceRegistration" runat="server" ConnectionString="<%$ ConnectionStrings:conStr %>"
        SelectCommand="sp_ms_person_registration_current" SelectCommandType="StoredProcedure"
        DeleteCommand="sp_ms_person_registration_delete" DeleteCommandType="StoredProcedure"
        InsertCommand="sp_ms_person_registration_add" InsertCommandType="StoredProcedure"
        UpdateCommand="sp_ms_person_registration_edit" UpdateCommandType="StoredProcedure" OnInserted="SqlDataSourceRegistration_Inserting">







SqlDataSourceRegistration.Inserting + = new SqlDataSourceCommandEventHandler(SqlDataSourceRegistration_Inserting);






SqlDataSourceRegistration.Inserting += new SqlDataSourceCommandEventHandler(SqlDataSourceRegistration_Inserting);

void SqlDataSourceRegistration_Inserting(object sender, SqlDataSourceCommandEventArgs e)
      {
          throw new NotImplementedException();

      }







仍然会收到错误请帮助我

如何处理异常,当我试图插入




Still getting Error pls help me
How to handle Exception which i am getting error while i was trying to insert

推荐答案

ConnectionStrings:conStr%>
SelectCommand = sp_ms_person_registration_current SelectCommandType = StoredProcedure
DeleteCommand = sp_ms_person_registration_delete DeleteCommandType = StoredProcedure
InsertCommand = sp_ms_person_registration_add InsertCommandType = StoredProcedure
UpdateCommand = sp_ms_person_registration_edit UpdateCommandType = StoredProcedure OnInserted = SqlDataSourceRegistration_Inserting>
ConnectionStrings:conStr %>" SelectCommand="sp_ms_person_registration_current" SelectCommandType="StoredProcedure" DeleteCommand="sp_ms_person_registration_delete" DeleteCommandType="StoredProcedure" InsertCommand="sp_ms_person_registration_add" InsertCommandType="StoredProcedure" UpdateCommand="sp_ms_person_registration_edit" UpdateCommandType="StoredProcedure" OnInserted="SqlDataSourceRegistration_Inserting">







SqlDataSourceRegistration.Inserting + = new SqlDataSourceCommandEventHandler(SqlDataSourceRegistration_Inserting);






SqlDataSourceRegistration.Inserting += new SqlDataSourceCommandEventHandler(SqlDataSourceRegistration_Inserting);

void SqlDataSourceRegistration_Inserting(object sender, SqlDataSourceCommandEventArgs e)
      {
          throw new NotImplementedException();

      }







仍然会收到错误请帮助我

如何处理我在尝试插入时出错的异常




Still getting Error pls help me
How to handle Exception which i am getting error while i was trying to insert


不确定我是否理解你的问题,但每次发生插入事件并且您的代码抛出了 SqlDataSourceRegistration_Inserting 方法 NotImplementedException 。这会导致插入失败。



因此,不要抛出异常,而是将其替换为需要添加的逻辑。
Not really sure if I understand your question correctly, but every time the Inserting event occurs and the SqlDataSourceRegistration_Inserting method is called a NotImplementedException is thrown by your code. This causes a situation that your inserts will fail.

So instead of throwing the exception replace it with the logic you need to add.


这篇关于如何使用Insert Command处理sqldatasource中的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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