dataGridView 控件的简单绑定
private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=.;database=pubs;user id=sa;password=123");
con.Open();
DataSet dst = new DataSet();
SqlCommand cmd =new SqlCommand ("select title_id,type from titles",con );
SqlDataAdapter dap = new SqlDataAdapter(cmd);
dap.Fill(dst);
this.dataGridView1.DataSource = dst.Tables[0].DefaultView;
}
//注;此处与web编程有有一句话的区别哟。。。