📄 catchexception.aspx
字号:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script language="C#" runat=server>
void Page_Load(Object sender , EventArgs e)
{
SqlConnection conNorthwind;
SqlCommand cmdSelect;
conNorthwind = new SqlConnection( @"Server=localhost;Database=Northwind;Connection Timeout=15" );
cmdSelect = new SqlCommand( "select * from Products", conNorthwind );
try {
conNorthwind.Open();
dgrdProducts.DataSource = cmdSelect.ExecuteReader();
dgrdProducts.DataBind();
conNorthwind.Close();
}
catch (Exception objException)
{
//Exception objException;
Response.Write( "We're sorry, we are experiencing technical problems..." );
Response.Write( "<hr>" );
Response.Write( "<li> Message: " + objException.Message );
Response.Write( "<li> Source: " + objException.Source );
Response.Write( "<li> Stack Trace: " + objException.StackTrace );
Response.Write( "<li> Target Site: " + objException.TargetSite.Name );
}
}
</Script>
<html>
<head><title>CatchException.aspx</title></head>
<body>
<asp:DataGrid
ID="dgrdProducts"
Runat="Server" />
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -