Binding to DataTable built from mutliple database tables
-
I populated an OleDb DataTable using a multi-table SELECT statement and need to bind some textboxes and comboboxes with the values from either one or the other table contained in the SELECT statement. However, when I run the program I get the following error: Child list for SerialNumber cannot be created What does that error mean? Thanks.
-
I populated an OleDb DataTable using a multi-table SELECT statement and need to bind some textboxes and comboboxes with the values from either one or the other table contained in the SELECT statement. However, when I run the program I get the following error: Child list for SerialNumber cannot be created What does that error mean? Thanks.
-
polishprogrammer, Maybe show the SQL you're trying to do and a bit of code... Regards, Gareth.
Thanks. Here's a piece of the SQL SELECT statement: SELECT ServiceDetails.SerialNumber, ServiceDetails.ManuDate, ServiceDetails.Manufacturer, " + "ServiceDetails.Customer, ServicDetails.GasType, " + "SerialNumber.SerialNumber, SerialNumber.Manufacturer, SerialNumber.ManufacturerDate, " + "SerialNumber.Owner, SerialNumber.GasType, " + "FROM SerialNumber, ServiceDetails WHERE " + "SerialNumber.SerialNumber=ServiceDetails.SerialNumber " + "AND SerialNumber.Manufacturer=ServiceDetails.Manufacturer " + "AND SerialNumber.ManufacturerDate=ServiceDetails.ManuDate " + "ORDER BY SerialNumber.SerialNumber" The databinding that causes the problem involves binding to, say, the Manufacturer field in the SerialNumber table due to the fact that the same field name exists in both tables. I need to qualify the name of the field, but am unsuccessful when trying it in a databinding context, such as: this.cbManuSer.DataBindings.Add("SelectedValue", dtSer, "SerialNumber.Manufacturer"); If I bind controls to fields in the datatable filled by the SQL SELECT statement given above that have unique names (not belonging to both tables), the binding works fine, but qualifying the name by table doesn't work. I get the Child list for x not created. There must be a piece I'm missing, but I could not find a discussion of this topic.
-
Thanks. Here's a piece of the SQL SELECT statement: SELECT ServiceDetails.SerialNumber, ServiceDetails.ManuDate, ServiceDetails.Manufacturer, " + "ServiceDetails.Customer, ServicDetails.GasType, " + "SerialNumber.SerialNumber, SerialNumber.Manufacturer, SerialNumber.ManufacturerDate, " + "SerialNumber.Owner, SerialNumber.GasType, " + "FROM SerialNumber, ServiceDetails WHERE " + "SerialNumber.SerialNumber=ServiceDetails.SerialNumber " + "AND SerialNumber.Manufacturer=ServiceDetails.Manufacturer " + "AND SerialNumber.ManufacturerDate=ServiceDetails.ManuDate " + "ORDER BY SerialNumber.SerialNumber" The databinding that causes the problem involves binding to, say, the Manufacturer field in the SerialNumber table due to the fact that the same field name exists in both tables. I need to qualify the name of the field, but am unsuccessful when trying it in a databinding context, such as: this.cbManuSer.DataBindings.Add("SelectedValue", dtSer, "SerialNumber.Manufacturer"); If I bind controls to fields in the datatable filled by the SQL SELECT statement given above that have unique names (not belonging to both tables), the binding works fine, but qualifying the name by table doesn't work. I get the Child list for x not created. There must be a piece I'm missing, but I could not find a discussion of this topic.
polishprogrammer, I am not to sure about the error, but i noticed you have an extra comma where there doesn't need to be one.
polishprogrammer wrote:
"SerialNumber.Owner, SerialNumber.GasType**,** " + "FROM SerialNumber, ServiceDetails WHERE " +
I am a bit puzzled by your db tables setup though. Why have 3 columns in 2 different tables that are storing the same values? Regards, Gareth.
-
polishprogrammer, I am not to sure about the error, but i noticed you have an extra comma where there doesn't need to be one.
polishprogrammer wrote:
"SerialNumber.Owner, SerialNumber.GasType**,** " + "FROM SerialNumber, ServiceDetails WHERE " +
I am a bit puzzled by your db tables setup though. Why have 3 columns in 2 different tables that are storing the same values? Regards, Gareth.
Thanks. I wound up just changing the names of the fields in one of the data tables and that worked for the data binding issue. Regarding the repetitive fields, well, it takes the 3 fields to uniquely identify a record, but I want to separate the data into two tables because the information in these particular tables aside from the primary key fields is quite different and used in different contexts, for different purposes. I suppose I could create a lookup table that would link an ID to the three fields and both tables could reference the look up table, but, well, that would require more software revision because the ServiceDetails table is a recent addition to the database in question whereas the SerialNumber table has been used extensively with its current structure for quite some time and I'd have to redo a bit of code to use a modified structure.