Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Binding to DataTable built from mutliple database tables

Binding to DataTable built from mutliple database tables

Scheduled Pinned Locked Moved C#
databasewpfwcfhelpquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    polishprogrammer
    wrote on last edited by
    #1

    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.

    G 1 Reply Last reply
    0
    • P polishprogrammer

      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.

      G Offline
      G Offline
      Gareth H
      wrote on last edited by
      #2

      polishprogrammer, Maybe show the SQL you're trying to do and a bit of code... Regards, Gareth.

      P 1 Reply Last reply
      0
      • G Gareth H

        polishprogrammer, Maybe show the SQL you're trying to do and a bit of code... Regards, Gareth.

        P Offline
        P Offline
        polishprogrammer
        wrote on last edited by
        #3

        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.

        G 1 Reply Last reply
        0
        • P polishprogrammer

          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.

          G Offline
          G Offline
          Gareth H
          wrote on last edited by
          #4

          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.

          P 1 Reply Last reply
          0
          • G Gareth H

            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.

            P Offline
            P Offline
            polishprogrammer
            wrote on last edited by
            #5

            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.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups