利用RowDeleted事件捕捉SQL错误(c#)
protected void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e)
{
if (e.Exception != null)
{
this.lblErrorMessage.Text = e.Exception.Message;
e.ExceptionHandled = true;
}
}
Untitled Page
File: Web.config
connectionString="Data Source=localhostSQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
vb.net版
http://www.w***3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Protected Sub SqlDataSource1_Deleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs)
If (e.Exception IsNot Nothing) Then
Me.lblErrorMessage.Text = e.Exception.Message
e.ExceptionHandled = True
End If
End Sub
https://www.111cn.net /1999/xhtml" >
Untitled Page
File: Web.config
connectionString="Data Source=localhostSQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />