using System;
using System.Data.SqlClient;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace Example04.Ex04_02
{
/// <summary>
/// Ex04_03 的摘要说明。
/// </summary>
public class Ex04_03 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label lblOrig;
protected System.Web.UI.WebControls.Label lblCurr;
protected System.Web.UI.WebControls.Button btnOpen;
protected System.Web.UI.WebControls.Button btnClose;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
protected SqlConnection myConn=new SqlConnection();

private void Page_Load(object sender, System.EventArgs e)
{
//用来设置connectionstring属性
string strConn="server=Localhost;uid=sa;pwd=;database=Northwind";
myConn.ConnectionString=strConn;
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{    
this.Load += new System.EventHandler(this.Page_Load); }
#endregion
}
public void myConn_StateChange(Object sender,StateChangeEventArgs e)
    {
     //显示初始与当前状态
     lblOrig.Text=e.OriginalState.ToString();
     lblCurr.Text=e.CurrentState.ToString();
    }
}
执行后提示:
c:\inetpub\wwwroot\Example04\Ex04_02\Ex04_03.aspx.cs(56): 应输入 class、delegate、enum、interface 或 struct加CLASS后则会出现更多的问题...