G
Guest
Ok, bear with me. This is a bit lengthy. This roughly explains a real-life
legacy data structure problem I’m having.
Assume a SQL Server 2000 database with 2 tables, Table1 and Table2.
Table1 has fields id1 (Integer, primary key, but NOT an identity field) and
content (varchar 10).
Table2 has fields id1 (integer), id2 (integer, identity field) and content
(varchar 10). The primary key of Table2 is id1/id2.
The 2 tables are joined by a relationship in which table1/id1 is the foreign
key of table2/id1. Also the options are set to cascade updates and deletes.
Now I go into SQL Server Enterprise Manager and:
1. Create a Table1 record with an id1 = 1
2. Create a Table2 record with an id1 = 1
3. I then go back into Table1 and change id1 to a value of 2. The change is
immediately reflected in the Table2 record. That’s exactly what I expected
and wanted.
Now the big question – can I get ADO to do the same thing in memory?
Now I create a Winforms app in VB/Dot Net 2.0. I add a dataset (xsd) to the
project and drag tables 1 and 2 onto the designer simultaneously so that the
relationship comes too. I then create a minimal class inheriting from the
dataset so I can fill Tables 1 and 2 from the server. I add a pair of
DataGridViews to the form to display Tables 1 and 2.
If I update Table1, id1, update to the database and reload the data, the
changes are reflected in Table2 as expected.
What I cannot figure out is how to immediately show the changes in the
Table2 grid without an update. In other words is there a way to make the
system do this?
Am I looking for something that does not exist?
legacy data structure problem I’m having.
Assume a SQL Server 2000 database with 2 tables, Table1 and Table2.
Table1 has fields id1 (Integer, primary key, but NOT an identity field) and
content (varchar 10).
Table2 has fields id1 (integer), id2 (integer, identity field) and content
(varchar 10). The primary key of Table2 is id1/id2.
The 2 tables are joined by a relationship in which table1/id1 is the foreign
key of table2/id1. Also the options are set to cascade updates and deletes.
Now I go into SQL Server Enterprise Manager and:
1. Create a Table1 record with an id1 = 1
2. Create a Table2 record with an id1 = 1
3. I then go back into Table1 and change id1 to a value of 2. The change is
immediately reflected in the Table2 record. That’s exactly what I expected
and wanted.
Now the big question – can I get ADO to do the same thing in memory?
Now I create a Winforms app in VB/Dot Net 2.0. I add a dataset (xsd) to the
project and drag tables 1 and 2 onto the designer simultaneously so that the
relationship comes too. I then create a minimal class inheriting from the
dataset so I can fill Tables 1 and 2 from the server. I add a pair of
DataGridViews to the form to display Tables 1 and 2.
If I update Table1, id1, update to the database and reload the data, the
changes are reflected in Table2 as expected.
What I cannot figure out is how to immediately show the changes in the
Table2 grid without an update. In other words is there a way to make the
system do this?
Am I looking for something that does not exist?