做最好的自己~~

Be My Personal Best!

导航

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编程有有一句话的区别哟。。。

posted on 2008-05-29 13:38  阿万  阅读(459)  评论(0编辑  收藏  举报