2012-07-07 57 views
0

何从LINQ的数据源赶上SQLExecption:的LinqDataSource异常

<asp:LinqDataSource ID="linq_tipo" runat="server" 
ContextTypeName="Linq_Clinica_Veterinaria" EntityTypeName="" 
TableName="tb_tipo_animals"> 
</asp:LinqDataSource> 

什么情况下,我能做到这一点,之前的Application_Error()长大的吗?

回答

1

捕获异常这样的:

protected void linq_tipo_Updating(object sender, 
     LinqDataSourceUpdateEventArgs e) { 
    if (e.SQLException != null) 
    { 
    //Handle the exception 
     e.ExceptionHandled = true;//Set to true as you have handled the exception 
    } } 

同样,你可以处理插入,删除,选择和其他活动。

+0

否....成像我有这样的LinqDataSource后: 如何捕捉mysqlexception?哪个控件? – Eriksson 2012-07-07 18:12:17