27,579
社区成员
发帖
与我相关
我的任务
分享
private void Form1_Load(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection( "user id=hxh;password=20080712;initial catalog=hxh;Server=XINAN0107\SQLEXPRESS");
conn.Open();
string strsql = "SELECT * FROM Student";
SqlDataAdapter da = new SqlDataAdapter(strsql,conn);
DataTable dt = new DataTable("Student");//
// DataSet dt=new DataSet()//可用这句
da.Fill(dt);
this.textBox1.Text = dt.Rows[0]["math"].ToString();
this.textBox2.Text = dt.Rows[0]["age"].ToString();
this.textBox3.Text = dt.Rows[0]["course"].ToString();
conn.Close();
}
SqlDataAdapter da = new SqlDataAdapter("select语句", conn);//加上
da.Fill(dt);