第1个回答 2009-02-21
比如你读到了sdr里面
SqlDataReader sdr=cmd.ExecuteReader();
while(sdr.Read())
{
textbox1.text=sdr[0].ToString(),
textbox2.text=sdr[1].ToString(),
textbox3.text=sdr[2].ToString(),
}
第2个回答 2009-02-28
protected void Form1_Load(object sender, EventArgs e)
{
myconnection.Open();
//连接打开,声明SqlConnection myconnection = new SqlConnection
//("DataSource=..........");
SqlDataAdapter myadapter=new SqlDataAdapter(str_select, myconnection);
//数据适配器,str_select="select id,name,age from table1 where..."。
myset.Clear();//清空数据集DataSet myset = new DataSet();
myadapter.Fill(myset,"table1");//参数为数据集对象和表明
myconnection.Close();//连接关闭
this.textbox1.text= myset.Tables[0].Rows[0][0].ToString();
this.textbox2.text= myset.Tables[0].Rows[0][1].ToString();
this.textbox3.text= myset.Tables[0].Rows[0][2].ToString();
}