Change Winform Query Question

  • Thread starter Thread starter Woody Splawn
  • Start date Start date
W

Woody Splawn

I had an experience this morning that I don't quite understand with VS 2003.
I have a Winform with the underlying data coming from three different
tables. This data for the Winform is obtained by use of a dataset. The
form has tabs. Data in the Contracts table goes to the Contracts tab, data
in the Students tables goes to the Students tab etc. For each of these
tables I have a SQLDataAdapter in the component tray of the Winform.
DaContracts, DaStudents, & DaArd. When I generate a Dataset for each of
these 3 data adapters I point to a DataSet I call DSMain (DsMain1). That
is, DSMain has schema involving all there of these tables and they are (in
the schema) related together in the proper way and in the same way they are
related in the underlying SQL 2000 tables. Sorry to be too wordy. Don't
know how to explain the problem, however, without saying at least that much.

It was necessary for me to add some fields to the main table (contracts).
These fields were not selected in the original query that produced the
contracts table in the DataSet Schema. I added the fields in the query of
the DaContracts DataAdapter and re-generated the dataset for that adapter.
I then tried to run the form and got back an error message of "Could not
create a child list for fields DrContractsArd". This is the data relations
name for the Contracts and Ard tables. I horsed around with it and finnaly
got the form back up and running as before but for future reference, I would
like to understand what happend. I think the moral of the story is that if
you add fields or change things in the future with regard to one table in a
dataset involving more than one table, it is not enough to re-generate the
dataset for just that table, you must regenerate the dataset for all the
tables. Is this right or are there other comments or items that others
would like to bring to my attention?

I am new to VS and may have made an incorrect assumption in tying these
three tables together in one dataset. Maybe each table should have a
dataset of it's own. I don't know. I did it this way in the first place
for reasons I don't remember other than, it worked.
 
I just set up your scenario and had no problems. When adding fields to one
relation.. However, I set up the relationship manually. On form Load., i'm
not sure how you did it.

My Code
Dim dc1, dc2 As DataColumn

dc1 = Ds1.Tables("Suppliers").Columns("ID")

dc2 = Ds1.Tables("Orders").Columns("SupplierID")

Dim rel As DataRelation

rel = New DataRelation("SuppliersToOrders", dc1, dc2)

Ds1.Relations.Add(rel)

dgSuppliers.DataSource = Ds1

dgSuppliers.DataMember = "Suppliers"

DataGrid1.DataSource = Ds1

DataGrid1.DataMember = "Suppliers"



dgOrders.DataSource = Ds1

dgOrders.DataMember = "Suppliers.SuppliersToOrders"




--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
 
I just set up your scenario and had no problems. When adding fields to one
relation.. However, I set up the relationship manually. On form Load., i'm
not sure how you did it.

My Code
Dim dc1, dc2 As DataColumn

dc1 = Ds1.Tables("Suppliers").Columns("ID")

dc2 = Ds1.Tables("Orders").Columns("SupplierID")

Dim rel As DataRelation

rel = New DataRelation("SuppliersToOrders", dc1, dc2)

Ds1.Relations.Add(rel)

dgSuppliers.DataSource = Ds1

dgSuppliers.DataMember = "Suppliers"

DataGrid1.DataSource = Ds1

DataGrid1.DataMember = "Suppliers"



dgOrders.DataSource = Ds1

dgOrders.DataMember = "Suppliers.SuppliersToOrders"




--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
Woody Splawn said:
I had an experience this morning that I don't quite understand with VS 2003.
I have a Winform with the underlying data coming from three different
tables. This data for the Winform is obtained by use of a dataset. The
form has tabs. Data in the Contracts table goes to the Contracts tab, data
in the Students tables goes to the Students tab etc. For each of these
tables I have a SQLDataAdapter in the component tray of the Winform.
DaContracts, DaStudents, & DaArd. When I generate a Dataset for each of
these 3 data adapters I point to a DataSet I call DSMain (DsMain1). That
is, DSMain has schema involving all there of these tables and they are (in
the schema) related together in the proper way and in the same way they are
related in the underlying SQL 2000 tables. Sorry to be too wordy. Don't
know how to explain the problem, however, without saying at least that much.

It was necessary for me to add some fields to the main table (contracts).
These fields were not selected in the original query that produced the
contracts table in the DataSet Schema. I added the fields in the query of
the DaContracts DataAdapter and re-generated the dataset for that adapter.
I then tried to run the form and got back an error message of "Could not
create a child list for fields DrContractsArd". This is the data relations
name for the Contracts and Ard tables. I horsed around with it and finnaly
got the form back up and running as before but for future reference, I would
like to understand what happend. I think the moral of the story is that if
you add fields or change things in the future with regard to one table in a
dataset involving more than one table, it is not enough to re-generate the
dataset for just that table, you must regenerate the dataset for all the
tables. Is this right or are there other comments or items that others
would like to bring to my attention?

I am new to VS and may have made an incorrect assumption in tying these
three tables together in one dataset. Maybe each table should have a
dataset of it's own. I don't know. I did it this way in the first place
for reasons I don't remember other than, it worked.



--
Regards - One Handed Man

Author : Fish .NET & Keep .NET

==============================
 
Back
Top