default.aspx
来自「Professional ASP.NET source code」· ASPX 代码 · 共 36 行
ASPX
36 行
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<Script Language="C#" runat="server">
public void Page_Load(Object sender, EventArgs e) {
SqlConnection connection;
SqlCommand command;
SqlDataReader reader;
string sqlSelect;
string dsn;
// Name dsn and sql select
dsn=ConfigurationSettings.AppSettings["DsnPubs"];
sqlSelect="Select * From stores";
// Connect to the database
connection = new SqlConnection(dsn);
command = new SqlCommand(sqlSelect, connection);
// Open the connection
connection.Open();
// Create the reader
reader = command.ExecuteReader();
// Populate the datagrid
datagrid1.DataSource = reader;
datagrid1.DataBind();
// Close the connection
connection.Close();
}
</Script>
<asp:datagrid id="datagrid1" runat="server" />
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?