if(!IsPostBack)
{
string dsn = ConfigurationSettings.AppSettings["TRS"];
SqlConnection myConnection = new SqlConnection(dsn);
string mySelectQuery="select a.shopcode,a.shopname,a.shopchief,a.shopphone,a.shopfax, a.setupdate,a.memo,a.shopaddress,b.areaname from Shopdata as a left outer join area as b on a.areacode=b.areacode where a.ShopCode=''"+ShopCode+"''";
SqlCommand cmd=new SqlCommand(mySelectQuery,myConnection) ;
myConnection.Open ();
SqlDataReader dr=cmd.ExecuteReader();
while(dr.Read())
{
lbCode.Text=dr["shopcode"].ToString();
txtName.Text=dr["shopname"].ToString();
txtChief.Text=dr["shopchief"].ToString();
DateTimeBox1.Text =dr["setupdate"].ToString();
ddlArea.SelectedItem.Text=dr["areaname"].ToString();
txtAddress.Text=dr["shopaddress"].ToString();
txtFax.Text=dr["shopfax"].ToString();
txtMemo.Text=dr["memo"].ToString();
txtPhone.Text =dr["shopphone"].ToString();
}
dr.Close ();
cmd.Dispose ();
myConnection.Close ();
}
转载于:https://www.cnblogs.com/synge/archive/2007/10/28/940717.html