绑定两个表并在 datagridview C# Winforms SQLite 中显示
Binding two tables and show it in the datagridview C# Winforms SQLite
基本上我有一个已经有列的数据网格视图。
每次我尝试在 datagridview 中显示数据时,它都会生成新列,而不是进入我已有的列。
;-;
enter image description here
SQLiteDataAdapter adapter = new SQLiteDataAdapter("SELECT members.name, members.number, members.age, members.occupation, jobs.sector FROM members LEFT OUTER JOIN jobs ON members.occupation = jobs.name", conn);
DataSet ds = new DataSet();
ds.Tables.Add("members");
adapter.Fill(ds, "members");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "members";
dataGridView1.AutoGenerateColumns=false;
基本上我有一个已经有列的数据网格视图。
每次我尝试在 datagridview 中显示数据时,它都会生成新列,而不是进入我已有的列。
;-;
enter image description here
SQLiteDataAdapter adapter = new SQLiteDataAdapter("SELECT members.name, members.number, members.age, members.occupation, jobs.sector FROM members LEFT OUTER JOIN jobs ON members.occupation = jobs.name", conn);
DataSet ds = new DataSet();
ds.Tables.Add("members");
adapter.Fill(ds, "members");
dataGridView1.DataSource = ds;
dataGridView1.DataMember = "members";
dataGridView1.AutoGenerateColumns=false;