Cześć,
mam dwie tabele o standardowych relacjach
Categories: id | name,
Products: id | name | category_id
później tworzę DataRelation żeby to się ładnie pokazywało (i w miarę automatycznie ;) ) w dataGridView,
niestety przy próbie wywołania Update przez adaptera
OdbcDataAdapter adapter = new OdbcDataAdapter();
OdbcCommandBuilder cb = new OdbcCommandBuilder(adapter);
adapter.Update(ds, "products");
dostaję "Właściwość DataAdapter.SelectCommand musi zostać zainicjowana."
Co zrobić? Nigdzie nie znalazłem wyjaśnienia jak to ma działać razem z używaniem DataRelation...
Poniżej kod na DataRelation:
BindingSource bCategories = new BindingSource();
BindingSource bProducts = new BindingSource();
DataSet ds = new DataSet();
OdbcDataAdapter adapter = new OdbcDataAdapter("select * from categories", odbcconnection);
adapter.Fill(ds ,"categories");
OdbcDataAdapter adapter2 = new OdbcDataAdapter("select * from products", odbcconnection);
adapter2.Fill(ds, "products");
ds.Relations.Add("abc", ds.Tables["categories"].Columns["id"], ds.Tables["products"].Columns["category_id"]);
bCategories.DataSource = ds;
bCategories.DataMember = "categories";
bProducts.DataSource = bCategories;
bProducts.DataMember = "abc";
dataGridView1.DataSource = bCategories;
dataGridView2.DataSource = bProducts;