如何使用Insert Command处理sqldatasource中的异常 [英] how to handling exception in sqldatasource using Insert Command
问题描述
<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 theInserting
event occurs and theSqlDataSourceRegistration_Inserting
method is called aNotImplementedException
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屋!