📄 把数据库中的字段输出到控件上.txt
字号:
方法一
if (!IsPostBack)
{
SqlConnection con = db.creatcon();
con.Open();
SqlCommand cmd = new SqlCommand("select companyname from companyname",con);
SqlDataReader sdr = cmd.ExecuteReader();
while (sdr.Read())
{
this.Label1.Text = Convert.ToString(sdr["companyname"]);
} 方法二
SqlConnection con = db.creatcon(); con.Open(); SqlCommand cmd = new SqlCommand("select companyname from companyname",con);this.Label1.Text = Convert.ToString(cmd.ExecuteSaler());
private void takecountlist()//帮顶显示纤细信息
{
SqlConnection con = db.creatcon();
con.Open();
SqlCommand cmd = new SqlCommand("select * from contract A left join projects B ON A.tpid=B.pid left join client C ON A.tcid=C.cid where tid=@tid", con);
cmd.Parameters.Add("@tid",SqlDbType.VarChar);
cmd.Parameters["@tid"].Value = Request.QueryString["TID"].ToString();
SqlDataReader sdr = cmd.ExecuteReader();
if (sdr.Read())
{
this.txtunumber.Text=sdr["cid"].ToString();
this.txtuname.Text=sdr["cname"].ToString();
this.txtusex.Text=sdr["csex"].ToString();
this.txtubank.Text=sdr["cbank"].ToString();
this.txtuemal.Text=sdr["cemal"].ToString();
this.txtuaddress.Text=sdr["caddress"].ToString();
this.txtushuihao.Text=sdr["ctex"].ToString();
this.txtudanwei.Text=sdr["cdanwei"].ToString();
this.txtubanknumber.Text=sdr["caccount"].ToString();
this.txtutel.Text=sdr["ctel"].ToString();
this.txtpcount.Text = sdr["pdescribe"].ToString();
this.txtpmoney.Text = sdr["psummoney"].ToString();
this.txtpname.Text = sdr["pname"].ToString();
this.txtpperson.Text = sdr["pmanger"].ToString();
this.txtpnumber.Text = sdr["pid"].ToString();
this.txttnubber.Text = sdr["tid"].ToString();
this.txttendtime.Text = sdr["tendtime"].ToString();
this.txttreadymoney.Text = sdr["treadymoney"].ToString();
this.txtttotalmoney.Text = sdr["ttotamoney"].ToString();
this.txttstate.Text = sdr["tstate"].ToString();
this.txttcount.Text = sdr["tcontent"].ToString();
this.txttbegintime.Text = sdr["tbegintime"].ToString();
}
con.Close();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -