
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<HTML>
	<HEAD>
		<title>使用DataAdapter填充数据到DataSet示例</title>
		<script language="C#" runat="server" id="Script1">
		
			void Page_Load(object sender, System.EventArgs e)
			{
				string ConnectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionSqlServer"];
				string Sql = "SELECT EmployeeID, LastName, FirstName,Title, TitleOfCourtesy, BirthDate FROM Employees";

				// 创建SqlConnection对象
				// 创建DataAdapter对象并初始化
				SqlConnection thisConnection = new SqlConnection(ConnectionString);
				SqlDataAdapter adapter = new SqlDataAdapter(Sql, thisConnection);

				// 创建DataSet对象
				DataSet data = new DataSet();

				// 填充数据到DataSet
				adapter.Fill(data);

				// 数据绑定
				myDataGrid.DataSource = data;
				myDataGrid.DataBind();
			}
		
		</script>
	</HEAD>
	<body>
		<form id="Form1" method="post" runat="server">
			<h3>使用DataAdapter填充数据到DataSet示例</h3>
			<asp:datagrid id="myDataGrid" runat="server"></asp:datagrid>
		</form>
	</body>
</HTML>
