?? address.aspx.cs
字號(hào):
?using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
public partial class Address : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//讀取數(shù)據(jù)庫(kù)連接字符串
string settings = Convert.ToString(ConfigurationManager.ConnectionStrings["SqlServices"]);
//創(chuàng)建數(shù)據(jù)庫(kù)連接對(duì)象
SqlConnection myconn = new SqlConnection(settings);
myconn.Open();
string strsql = "select * from AddressBook";
SqlCommand myCommand = new SqlCommand(strsql, myconn);
//執(zhí)行數(shù)據(jù)操作命令
//SqlDataReader讀取數(shù)據(jù)到記錄集后,會(huì)自動(dòng)關(guān)閉數(shù)據(jù)庫(kù)的連接
SqlDataReader result = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
gv_address.DataSource = result;
gv_address.DataBind();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("AddAddress.aspx");
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -