这是我的代码
private void button3_Click(object sender, EventArgs e)
{
ds= new DataSet();
sda=new SqlDataAdapter("select * from empdtl",econ.con);
sda.Fill(ds,"empdtl");
dataGridView1.DataMember = ds;
dataGridView1.DataSource = "empdtl";
}
答案 0 :(得分:3)
您需要在DataSource
属性和DataMember
属性中的DataTable名称中传递数据集
dataGridView1.DataMember = "empdtl";
dataGridView1.DataSource = ds;