Data Relations with DataTable Class

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anil Gupte

    #1

    Data Relations with DataTable Class

    After reading a tutorial and fiddling, I finally got this to work. I can
    now put two tables created with a DataTable class into a DataRelation.
    Phew! And it works!
    Dim tblSliceInfo As New DataTable("Slic eInfo")

    Dim tblSliceRatings As New DataTable("Slic eRatings")

    '.... All the adding datacolumns, datarows, etc. goes here..

    DatasetInit.Tab les.Add(tblSlic eInfo)

    DatasetInit.Tab les.Add(tblSlic eRatings)

    Dim colSliceInfo As DataColumn

    Dim colSliceRatings As DataColumn

    colSliceInfo = tblSliceInfo.Co lumns("SliceID" )

    colSliceRatings = tblSliceRatings .Columns("Slice RatingsID")

    Dim SliceIDRelation As DataRelation

    SliceIDRelation = New DataRelation("S liceIDRelation" , colSliceInfo,
    colSliceRatings )

    DatasetInit.Rel ations.Add(Slic eIDRelation)

    Anyway, what I want to do now is that instead of using those tables as
    above, I want to use a SQL statement so that I can select the correct
    records from the child table. How do I do this? I am planning to bind the
    values in the fields to textboxes and then allow editing of those.

    Please give me a clue how to go about it.
    Thanx,
    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

    www.icinema.com


  • Cor Ligthert [MVP]

    #2
    Re: Data Relations with DataTable Class

    Anil,

    I give you only this link, I think that you can than go on.

    http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx

    The missing link you have are the bad written parts about the datarowstate
    on MSDN.

    Cor

    "Anil Gupte" <anil-list@icinema.co mschreef in bericht
    news:Oj9z1BsGHH A.2456@TK2MSFTN GP06.phx.gbl...
    After reading a tutorial and fiddling, I finally got this to work. I can
    now put two tables created with a DataTable class into a DataRelation.
    Phew! And it works!
    Dim tblSliceInfo As New DataTable("Slic eInfo")
    >
    Dim tblSliceRatings As New DataTable("Slic eRatings")
    >
    '.... All the adding datacolumns, datarows, etc. goes here..
    >
    DatasetInit.Tab les.Add(tblSlic eInfo)
    >
    DatasetInit.Tab les.Add(tblSlic eRatings)
    >
    Dim colSliceInfo As DataColumn
    >
    Dim colSliceRatings As DataColumn
    >
    colSliceInfo = tblSliceInfo.Co lumns("SliceID" )
    >
    colSliceRatings = tblSliceRatings .Columns("Slice RatingsID")
    >
    Dim SliceIDRelation As DataRelation
    >
    SliceIDRelation = New DataRelation("S liceIDRelation" , colSliceInfo,
    colSliceRatings )
    >
    DatasetInit.Rel ations.Add(Slic eIDRelation)
    >
    Anyway, what I want to do now is that instead of using those tables as
    above, I want to use a SQL statement so that I can select the correct
    records from the child table. How do I do this? I am planning to bind
    the values in the fields to textboxes and then allow editing of those.
    >
    Please give me a clue how to go about it.
    Thanx,
    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

    www.icinema.com
    >
    >

    Comment

    • Anil Gupte

      #3
      Re: Data Relations with DataTable Class

      Cor:

      Thanx for your input. Unfrtunately, that example uses an access database,
      but I am using a DataTable class, which I think will be more secure, since
      people will not be able to get their hands on the data. The problem I am
      having is this. If you see the code below:
      DatasetInit.Tab les.Add(tblSlic eInfo) ' tblSliceInfo= "SliceInfo"
      DatasetInit.Tab les.Add(tblSlic eRatings) ' tblSliceRatings = "SliceRatin gs"

      Dim colSliceInfo As DataColumn
      Dim colSliceRatings As DataColumn
      colSliceInfo = tblSliceInfo.Co lumns("SliceID" )
      colSliceRatings = tblSliceRatings .Columns("Slice RatingsID")
      Dim SliceIDRelation As DataRelation
      SliceIDRelation = New DataRelation("S liceIDRelation" , colSliceInfo,
      colSliceRatings )
      DatasetInit.Rel ations.Add(Slic eIDRelation)

      DataGrid1.SetDa taBinding(Datas etInit, "SliceInfo" )
      DataGrid2.SetDa taBinding(Datas etInit, "SliceInfo.Slic eIdRelation")

      TextBox1.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.Slic eID")
      TextBox2.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.Slic eTitle")
      TextBox3.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.Slic eStartAbs")
      TextBox4.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.L3Fi lename")

      TextBox5.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingName")
      TextBox6.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingValue")
      TextBox7.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingName")
      TextBox8.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingValue")

      Everything works great in the Datagrids. Datagrid1 shows the rows in the
      master/parent table Datagrid2 shows the child rows in the child table. In
      the text boxes, Textbox1 thru 4 are fine and as I step through the rows in
      Datagrid1, their value changes. Unfortunately, the values in the Textbox5
      thru 8 do not change at all, leading me to believe that they are not somehow
      bound. Also, how do I make Textbox7 and 8 have the value from the second
      child row (right now it just repeats what is in textbox5 and 6 respectively)

      Thanx for any help.

      --
      Anil Gupte
      Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

      www.icinema.com


      "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
      news:OXWUXT1GHH A.1216@TK2MSFTN GP05.phx.gbl...
      Anil,
      >
      I give you only this link, I think that you can than go on.
      >
      http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
      >
      The missing link you have are the bad written parts about the datarowstate
      on MSDN.
      >
      Cor
      >
      "Anil Gupte" <anil-list@icinema.co mschreef in bericht
      news:Oj9z1BsGHH A.2456@TK2MSFTN GP06.phx.gbl...
      >After reading a tutorial and fiddling, I finally got this to work. I can
      >now put two tables created with a DataTable class into a DataRelation.
      >Phew! And it works!
      >Dim tblSliceInfo As New DataTable("Slic eInfo")
      >>
      >Dim tblSliceRatings As New DataTable("Slic eRatings")
      >>
      >'.... All the adding datacolumns, datarows, etc. goes here..
      >>
      >DatasetInit.Ta bles.Add(tblSli ceInfo)
      >>
      >DatasetInit.Ta bles.Add(tblSli ceRatings)
      >>
      >Dim colSliceInfo As DataColumn
      >>
      >Dim colSliceRatings As DataColumn
      >>
      >colSliceInfo = tblSliceInfo.Co lumns("SliceID" )
      >>
      >colSliceRating s = tblSliceRatings .Columns("Slice RatingsID")
      >>
      >Dim SliceIDRelation As DataRelation
      >>
      >SliceIDRelatio n = New DataRelation("S liceIDRelation" , colSliceInfo,
      >colSliceRating s)
      >>
      >DatasetInit.Re lations.Add(Sli ceIDRelation)
      >>
      >Anyway, what I want to do now is that instead of using those tables as
      >above, I want to use a SQL statement so that I can select the correct
      >records from the child table. How do I do this? I am planning to bind
      >the values in the fields to textboxes and then allow editing of those.
      >>
      >Please give me a clue how to go about it.
      >Thanx,
      >--
      >Anil Gupte
      >www.keeninc.net
      >www.icinema.com
      >>
      >>
      >
      >

      Comment

      • RobinS

        #4
        Re: Data Relations with DataTable Class

        This may help. You might want to check out the BindingSource
        component; using this for your databinding will more
        easily enable the parent/child binding. Here's an example;
        hopefully there will be something in here that you can use.

        This example is for a form with two grids on it, and a bunch
        of textboxes. One grid is the parent, the other is the
        children, and the textboxes are bound to the parent.
        ---------------------------

        I have a dataset that has two tables: Customers and Orders.
        (This runs against Northwind, so if you have that
        installed, you can try this out.)

        I set up a strongly-typed dataset using the Data Set
        Designer with both of those tables in it, and there is
        a field called CustomerID in the Orders table that links
        to the CustomerID table in Customers. So Orders have a
        Customer as a parent. The data relation between
        the customer and the orders is defined as FK_Orders_Custo mers.

        (You can set up your dataset however you like.)

        This is in Form_Load:

        'First, populate the dataset.
        Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )

        'Set the data source for the binding source to the dataset.
        CustomersBindin gSource.DataSou rce = nwData
        'Add this so it knows which table to use .
        CustomersBindin gSource.DataMem ber = "Customers"
        'Set the data source for the grid to the customers binding source.
        CustomersDataGr idView.DataSour ce = CustomersBindin gSource

        'Add the binding for the child; set its binding source to the same
        ' one as the parent.
        Customers_Order sBindingSource. DataSource = CustomersBindin gSource
        'Set the datamember to the foreign key joining the two tables.
        ' You can see this on your CustomersDataSe t diagram.
        Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
        'Set the data source on the child grid to points at its
        ' binding source.
        OrdersDataGridV iew.DataSource = Customers_Order sBindingSource

        AddTextBoxDataB indings()
        AddComboBoxData Bindings()

        Here are the routines that bind the textboxes and combo box
        in case you want them. These only bind to the Customers table,
        but you can easily bind textboxes to the children by binding
        to the Customers_Order sBindingSource instead of the
        CustomersBindin gSource.

        Private Sub AddTextBoxDataB indings()
        'Bind each text box to the appropriate field in the
        ' CustomersBindin gSource
        CustomerIDTextB ox.DataBindings .Add("Text", _
        CustomersBindin gSource, "CustomerID ")
        ContactNameText Box.DataBinding s.Add("Text", _
        CustomersBindin gSource, "ContactNam e")
        CompanyNameText Box.DataBinding s.Add("Text", _
        CustomersBindin gSource, "CompanyNam e")
        ContactPhoneTex tBox.DataBindin gs.Add("Text", _
        CustomersBindin gSource, "Phone")
        End Sub

        Private Sub AddComboBoxData Bindings()
        ContactsComboBo x.DataSource = CustomersBindin gSource
        ContactsComboBo x.DisplayMember = "ContactNam e"
        ContactsComboBo x.ValueMember = "CustomerID "
        End Sub

        This information came out of Brian Noyes's book on Data Binding.
        ---------------------------

        As for displaying info from specific rows in textboxes
        5 through 8, you could attach a handler to the positionChanged
        event on the binding source of the parents. In the event, you
        could check for multiple records in the children (probably
        using the binding source, maybe BindingSource.C ount?)
        and populate the textboxes accordingly.

        Hope this helps.
        Robin S.
        -----------------------------
        "Anil Gupte" <anil-list@icinema.co mwrote in message
        news:e%23STCD2G HHA.3780@TK2MSF TNGP02.phx.gbl. ..
        Cor:
        >
        Thanx for your input. Unfrtunately, that example uses an access database,
        but I am using a DataTable class, which I think will be more secure, since
        people will not be able to get their hands on the data. The problem I am
        having is this. If you see the code below:
        DatasetInit.Tab les.Add(tblSlic eInfo) ' tblSliceInfo= "SliceInfo"
        DatasetInit.Tab les.Add(tblSlic eRatings) ' tblSliceRatings = "SliceRatin gs"
        >
        Dim colSliceInfo As DataColumn
        Dim colSliceRatings As DataColumn
        colSliceInfo = tblSliceInfo.Co lumns("SliceID" )
        colSliceRatings = tblSliceRatings .Columns("Slice RatingsID")
        Dim SliceIDRelation As DataRelation
        SliceIDRelation = New DataRelation("S liceIDRelation" , colSliceInfo,
        colSliceRatings )
        DatasetInit.Rel ations.Add(Slic eIDRelation)
        >
        DataGrid1.SetDa taBinding(Datas etInit, "SliceInfo" )
        DataGrid2.SetDa taBinding(Datas etInit, "SliceInfo.Slic eIdRelation")
        >
        TextBox1.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.Slic eID")
        TextBox2.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.Slic eTitle")
        TextBox3.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.Slic eStartAbs")
        TextBox4.DataBi ndings.Add("Tex t", DatasetInit, "SliceInfo.L3Fi lename")
        >
        TextBox5.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingName")
        TextBox6.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingValue")
        TextBox7.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingName")
        TextBox8.DataBi ndings.Add("Tex t", DatasetInit, "SliceRatings.R atingValue")
        >
        Everything works great in the Datagrids. Datagrid1 shows the rows in the
        master/parent table Datagrid2 shows the child rows in the child table. In
        the text boxes, Textbox1 thru 4 are fine and as I step through the rows in
        Datagrid1, their value changes. Unfortunately, the values in the Textbox5
        thru 8 do not change at all, leading me to believe that they are not
        somehow bound. Also, how do I make Textbox7 and 8 have the value from the
        second child row (right now it just repeats what is in textbox5 and 6
        respectively)
        >
        Thanx for any help.
        >
        --
        Anil Gupte
        Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

        www.icinema.com
        >
        >
        "Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
        news:OXWUXT1GHH A.1216@TK2MSFTN GP05.phx.gbl...
        >Anil,
        >>
        >I give you only this link, I think that you can than go on.
        >>
        >http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
        >>
        >The missing link you have are the bad written parts about the
        >datarowstate on MSDN.
        >>
        >Cor
        >>
        >"Anil Gupte" <anil-list@icinema.co mschreef in bericht
        >news:Oj9z1BsGH HA.2456@TK2MSFT NGP06.phx.gbl.. .
        >>After reading a tutorial and fiddling, I finally got this to work. I
        >>can now put two tables created with a DataTable class into a
        >>DataRelatio n. Phew! And it works!
        >>Dim tblSliceInfo As New DataTable("Slic eInfo")
        >>>
        >>Dim tblSliceRatings As New DataTable("Slic eRatings")
        >>>
        >>'.... All the adding datacolumns, datarows, etc. goes here..
        >>>
        >>DatasetInit.T ables.Add(tblSl iceInfo)
        >>>
        >>DatasetInit.T ables.Add(tblSl iceRatings)
        >>>
        >>Dim colSliceInfo As DataColumn
        >>>
        >>Dim colSliceRatings As DataColumn
        >>>
        >>colSliceInf o = tblSliceInfo.Co lumns("SliceID" )
        >>>
        >>colSliceRatin gs = tblSliceRatings .Columns("Slice RatingsID")
        >>>
        >>Dim SliceIDRelation As DataRelation
        >>>
        >>SliceIDRelati on = New DataRelation("S liceIDRelation" , colSliceInfo,
        >>colSliceRatin gs)
        >>>
        >>DatasetInit.R elations.Add(Sl iceIDRelation)
        >>>
        >>Anyway, what I want to do now is that instead of using those tables as
        >>above, I want to use a SQL statement so that I can select the correct
        >>records from the child table. How do I do this? I am planning to bind
        >>the values in the fields to textboxes and then allow editing of those.
        >>>
        >>Please give me a clue how to go about it.
        >>Thanx,
        >>--
        >>Anil Gupte
        >>www.keeninc.net
        >>www.icinema.com
        >>>
        >>>
        >>
        >>
        >
        >

        Comment

        • Anil Gupte

          #5
          Re: Data Relations with DataTable Class

          Thanx, my main problem is trying to do this with a DataTable (in memory, so
          there is no DataConnection object, and no physical database). I have done
          it before with a MS Access DB. And I have done the Parent table bindings
          succesfully in he current problem. It is just that I have not been able to
          do the Child table bindings to text boxes. Basically, I know that I need to
          find a DataRow, and then DataRow.ChildRo ws and then bind Items(n) to each
          text box. I want to do databinding so I can write just one simple update
          function and update my DataTable.

          Thanx,
          --
          Anil Gupte
          Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

          www.icinema.com

          "RobinS" <RobinS@NoSpam. yah.nonewrote in message
          news:icednXfTv6 ek8-fYnZ2dnUVZ_siln Z2d@comcast.com ...
          This may help. You might want to check out the BindingSource
          component; using this for your databinding will more
          easily enable the parent/child binding. Here's an example;
          hopefully there will be something in here that you can use.
          >
          This example is for a form with two grids on it, and a bunch
          of textboxes. One grid is the parent, the other is the
          children, and the textboxes are bound to the parent.
          ---------------------------
          >
          I have a dataset that has two tables: Customers and Orders.
          (This runs against Northwind, so if you have that
          installed, you can try this out.)
          >
          I set up a strongly-typed dataset using the Data Set
          Designer with both of those tables in it, and there is
          a field called CustomerID in the Orders table that links
          to the CustomerID table in Customers. So Orders have a
          Customer as a parent. The data relation between
          the customer and the orders is defined as FK_Orders_Custo mers.
          >
          (You can set up your dataset however you like.)
          >
          This is in Form_Load:
          >
          'First, populate the dataset.
          Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
          >
          'Set the data source for the binding source to the dataset.
          CustomersBindin gSource.DataSou rce = nwData
          'Add this so it knows which table to use .
          CustomersBindin gSource.DataMem ber = "Customers"
          'Set the data source for the grid to the customers binding source.
          CustomersDataGr idView.DataSour ce = CustomersBindin gSource
          >
          'Add the binding for the child; set its binding source to the same
          ' one as the parent.
          Customers_Order sBindingSource. DataSource = CustomersBindin gSource
          'Set the datamember to the foreign key joining the two tables.
          ' You can see this on your CustomersDataSe t diagram.
          Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
          'Set the data source on the child grid to points at its
          ' binding source.
          OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
          >
          AddTextBoxDataB indings()
          AddComboBoxData Bindings()
          >
          Here are the routines that bind the textboxes and combo box
          in case you want them. These only bind to the Customers table,
          but you can easily bind textboxes to the children by binding
          to the Customers_Order sBindingSource instead of the
          CustomersBindin gSource.
          >
          Private Sub AddTextBoxDataB indings()
          'Bind each text box to the appropriate field in the
          ' CustomersBindin gSource
          CustomerIDTextB ox.DataBindings .Add("Text", _
          CustomersBindin gSource, "CustomerID ")
          ContactNameText Box.DataBinding s.Add("Text", _
          CustomersBindin gSource, "ContactNam e")
          CompanyNameText Box.DataBinding s.Add("Text", _
          CustomersBindin gSource, "CompanyNam e")
          ContactPhoneTex tBox.DataBindin gs.Add("Text", _
          CustomersBindin gSource, "Phone")
          End Sub
          >
          Private Sub AddComboBoxData Bindings()
          ContactsComboBo x.DataSource = CustomersBindin gSource
          ContactsComboBo x.DisplayMember = "ContactNam e"
          ContactsComboBo x.ValueMember = "CustomerID "
          End Sub
          >
          This information came out of Brian Noyes's book on Data Binding.
          ---------------------------
          >
          As for displaying info from specific rows in textboxes
          5 through 8, you could attach a handler to the positionChanged
          event on the binding source of the parents. In the event, you
          could check for multiple records in the children (probably
          using the binding source, maybe BindingSource.C ount?)
          and populate the textboxes accordingly.
          >
          Hope this helps.
          Robin S.
          -----------------------------
          "Anil Gupte" <anil-list@icinema.co mwrote in message
          news:e%23STCD2G HHA.3780@TK2MSF TNGP02.phx.gbl. ..
          >Cor:
          >>
          >Thanx for your input. Unfrtunately, that example uses an access
          >database, but I am using a DataTable class, which I think will be more
          >secure, since people will not be able to get their hands on the data.
          >The problem I am having is this. If you see the code below:
          >DatasetInit.Ta bles.Add(tblSli ceInfo) ' tblSliceInfo= "SliceInfo"
          >DatasetInit.Ta bles.Add(tblSli ceRatings) ' tblSliceRatings =
          >"SliceRating s"
          >>
          >Dim colSliceInfo As DataColumn
          >Dim colSliceRatings As DataColumn
          >colSliceInfo = tblSliceInfo.Co lumns("SliceID" )
          >colSliceRating s = tblSliceRatings .Columns("Slice RatingsID")
          >Dim SliceIDRelation As DataRelation
          >SliceIDRelatio n = New DataRelation("S liceIDRelation" , colSliceInfo,
          >colSliceRating s)
          >DatasetInit.Re lations.Add(Sli ceIDRelation)
          >>
          >DataGrid1.SetD ataBinding(Data setInit, "SliceInfo" )
          >DataGrid2.SetD ataBinding(Data setInit, "SliceInfo.Slic eIdRelation")
          >>
          >TextBox1.DataB indings.Add("Te xt", DatasetInit, "SliceInfo.Slic eID")
          >TextBox2.DataB indings.Add("Te xt", DatasetInit, "SliceInfo.Slic eTitle")
          >TextBox3.DataB indings.Add("Te xt", DatasetInit, "SliceInfo.Slic eStartAbs")
          >TextBox4.DataB indings.Add("Te xt", DatasetInit, "SliceInfo.L3Fi lename")
          >>
          >TextBox5.DataB indings.Add("Te xt", DatasetInit, "SliceRatings.R atingName")
          >TextBox6.DataB indings.Add("Te xt", DatasetInit,
          >"SliceRatings. RatingValue")
          >TextBox7.DataB indings.Add("Te xt", DatasetInit, "SliceRatings.R atingName")
          >TextBox8.DataB indings.Add("Te xt", DatasetInit,
          >"SliceRatings. RatingValue")
          >>
          >Everything works great in the Datagrids. Datagrid1 shows the rows in the
          >master/parent table Datagrid2 shows the child rows in the child table.
          >In the text boxes, Textbox1 thru 4 are fine and as I step through the
          >rows in Datagrid1, their value changes. Unfortunately, the values in the
          >Textbox5 thru 8 do not change at all, leading me to believe that they are
          >not somehow bound. Also, how do I make Textbox7 and 8 have the value
          >from the second child row (right now it just repeats what is in textbox5
          >and 6 respectively)
          >>
          >Thanx for any help.
          >>
          >--
          >Anil Gupte
          >www.keeninc.net
          >www.icinema.com
          >>
          >>
          >"Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
          >news:OXWUXT1GH HA.1216@TK2MSFT NGP05.phx.gbl.. .
          >>Anil,
          >>>
          >>I give you only this link, I think that you can than go on.
          >>>
          >>http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
          >>>
          >>The missing link you have are the bad written parts about the
          >>datarowstat e on MSDN.
          >>>
          >>Cor
          >>>
          >>"Anil Gupte" <anil-list@icinema.co mschreef in bericht
          >>news:Oj9z1BsG HHA.2456@TK2MSF TNGP06.phx.gbl. ..
          >>>After reading a tutorial and fiddling, I finally got this to work. I
          >>>can now put two tables created with a DataTable class into a
          >>>DataRelation . Phew! And it works!
          >>>Dim tblSliceInfo As New DataTable("Slic eInfo")
          >>>>
          >>>Dim tblSliceRatings As New DataTable("Slic eRatings")
          >>>>
          >>>'.... All the adding datacolumns, datarows, etc. goes here..
          >>>>
          >>>DatasetInit. Tables.Add(tblS liceInfo)
          >>>>
          >>>DatasetInit. Tables.Add(tblS liceRatings)
          >>>>
          >>>Dim colSliceInfo As DataColumn
          >>>>
          >>>Dim colSliceRatings As DataColumn
          >>>>
          >>>colSliceIn fo = tblSliceInfo.Co lumns("SliceID" )
          >>>>
          >>>colSliceRati ngs = tblSliceRatings .Columns("Slice RatingsID")
          >>>>
          >>>Dim SliceIDRelation As DataRelation
          >>>>
          >>>SliceIDRelat ion = New DataRelation("S liceIDRelation" , colSliceInfo,
          >>>colSliceRati ngs)
          >>>>
          >>>DatasetInit. Relations.Add(S liceIDRelation)
          >>>>
          >>>Anyway, what I want to do now is that instead of using those tables as
          >>>above, I want to use a SQL statement so that I can select the correct
          >>>records from the child table. How do I do this? I am planning to bind
          >>>the values in the fields to textboxes and then allow editing of those.
          >>>>
          >>>Please give me a clue how to go about it.
          >>>Thanx,
          >>>--
          >>>Anil Gupte
          >>>www.keeninc.net
          >>>www.icinema.com
          >>>>
          >>>>
          >>>
          >>>
          >>
          >>
          >
          >

          Comment

          • RobinS

            #6
            Re: Data Relations with DataTable Class

            It's not a DataTable, it's a DataSet with multiple tables, right?

            Assuming that's true, my code should work; just replace the parts
            where it fills the dataset by accessing the database with your
            parts where you populate the dataset. You can still using the
            BindingSource components to lubricate the process. After they
            have made changes, you can invoke the EndEdit method on the
            BindingSource to save the changes on the screen to the
            underlying DataSet.

            If you were attached to a database, then after doing the EndEdit,
            you would invoke the Update method on the TableAdapter to
            cascade the changes down into the database. You won't have that
            part; you can save them however you want to after the DataTable
            is updated.

            I don't know of a way to bind different rows in a datagrid to
            the textboxes, though. I've read a lot of material about data
            binding, and have never seen anything that will do that. So
            be sure to let us know if you find something like that. The
            only way I could think of is to load them manually as the user
            steps through the parent records, as noted below.

            Good luck!

            Robin S.
            --------------------------------------
            "Anil Gupte" <anil-list@icinema.co mwrote in message
            news:OYg6fl5GHH A.4688@TK2MSFTN GP04.phx.gbl...
            Thanx, my main problem is trying to do this with a DataTable (in
            memory, so there is no DataConnection object, and no physical
            database). I have done it before with a MS Access DB. And I have
            done the Parent table bindings succesfully in he current problem. It
            is just that I have not been able to do the Child table bindings to
            text boxes. Basically, I know that I need to find a DataRow, and then
            DataRow.ChildRo ws and then bind Items(n) to each text box. I want to
            do databinding so I can write just one simple update function and
            update my DataTable.
            >
            Thanx,
            --
            Anil Gupte
            Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

            www.icinema.com
            >
            "RobinS" <RobinS@NoSpam. yah.nonewrote in message
            news:icednXfTv6 ek8-fYnZ2dnUVZ_siln Z2d@comcast.com ...
            >This may help. You might want to check out the BindingSource
            >component; using this for your databinding will more
            >easily enable the parent/child binding. Here's an example;
            >hopefully there will be something in here that you can use.
            >>
            >This example is for a form with two grids on it, and a bunch
            >of textboxes. One grid is the parent, the other is the
            >children, and the textboxes are bound to the parent.
            >---------------------------
            >>
            >I have a dataset that has two tables: Customers and Orders.
            >(This runs against Northwind, so if you have that
            >installed, you can try this out.)
            >>
            >I set up a strongly-typed dataset using the Data Set
            >Designer with both of those tables in it, and there is
            >a field called CustomerID in the Orders table that links
            >to the CustomerID table in Customers. So Orders have a
            >Customer as a parent. The data relation between
            >the customer and the orders is defined as FK_Orders_Custo mers.
            >>
            >(You can set up your dataset however you like.)
            >>
            >This is in Form_Load:
            >>
            > 'First, populate the dataset.
            > Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
            >>
            > 'Set the data source for the binding source to the dataset.
            > CustomersBindin gSource.DataSou rce = nwData
            > 'Add this so it knows which table to use .
            > CustomersBindin gSource.DataMem ber = "Customers"
            > 'Set the data source for the grid to the customers binding source.
            > CustomersDataGr idView.DataSour ce = CustomersBindin gSource
            >>
            > 'Add the binding for the child; set its binding source to the same
            > ' one as the parent.
            > Customers_Order sBindingSource. DataSource = CustomersBindin gSource
            > 'Set the datamember to the foreign key joining the two tables.
            > ' You can see this on your CustomersDataSe t diagram.
            > Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
            > 'Set the data source on the child grid to points at its
            > ' binding source.
            > OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
            >>
            > AddTextBoxDataB indings()
            > AddComboBoxData Bindings()
            >>
            >Here are the routines that bind the textboxes and combo box
            >in case you want them. These only bind to the Customers table,
            >but you can easily bind textboxes to the children by binding
            >to the Customers_Order sBindingSource instead of the
            >CustomersBindi ngSource.
            >>
            >Private Sub AddTextBoxDataB indings()
            > 'Bind each text box to the appropriate field in the
            > ' CustomersBindin gSource
            > CustomerIDTextB ox.DataBindings .Add("Text", _
            > CustomersBindin gSource, "CustomerID ")
            > ContactNameText Box.DataBinding s.Add("Text", _
            > CustomersBindin gSource, "ContactNam e")
            > CompanyNameText Box.DataBinding s.Add("Text", _
            > CustomersBindin gSource, "CompanyNam e")
            > ContactPhoneTex tBox.DataBindin gs.Add("Text", _
            > CustomersBindin gSource, "Phone")
            >End Sub
            >>
            >Private Sub AddComboBoxData Bindings()
            > ContactsComboBo x.DataSource = CustomersBindin gSource
            > ContactsComboBo x.DisplayMember = "ContactNam e"
            > ContactsComboBo x.ValueMember = "CustomerID "
            >End Sub
            >>
            >This information came out of Brian Noyes's book on Data Binding.
            >---------------------------
            >>
            >As for displaying info from specific rows in textboxes
            >5 through 8, you could attach a handler to the positionChanged
            >event on the binding source of the parents. In the event, you
            >could check for multiple records in the children (probably
            >using the binding source, maybe BindingSource.C ount?)
            >and populate the textboxes accordingly.
            >>
            >Hope this helps.
            >Robin S.
            >-----------------------------
            >"Anil Gupte" <anil-list@icinema.co mwrote in message
            >news:e%23STCD2 GHHA.3780@TK2MS FTNGP02.phx.gbl ...
            >>Cor:
            >>>
            >>Thanx for your input. Unfrtunately, that example uses an access
            >>database, but I am using a DataTable class, which I think will be
            >>more secure, since people will not be able to get their hands on the
            >>data. The problem I am having is this. If you see the code below:
            >>DatasetInit.T ables.Add(tblSl iceInfo) ' tblSliceInfo= "SliceInfo"
            >>DatasetInit.T ables.Add(tblSl iceRatings) ' tblSliceRatings =
            >>"SliceRatings "
            >>>
            >>Dim colSliceInfo As DataColumn
            >>Dim colSliceRatings As DataColumn
            >>colSliceInf o = tblSliceInfo.Co lumns("SliceID" )
            >>colSliceRatin gs = tblSliceRatings .Columns("Slice RatingsID")
            >>Dim SliceIDRelation As DataRelation
            >>SliceIDRelati on = New DataRelation("S liceIDRelation" , colSliceInfo,
            >>colSliceRatin gs)
            >>DatasetInit.R elations.Add(Sl iceIDRelation)
            >>>
            >>DataGrid1.Set DataBinding(Dat asetInit, "SliceInfo" )
            >>DataGrid2.Set DataBinding(Dat asetInit, "SliceInfo.Slic eIdRelation")
            >>>
            >>TextBox1.Data Bindings.Add("T ext", DatasetInit, "SliceInfo.Slic eID")
            >>TextBox2.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceInfo.Sl iceTitle")
            >>TextBox3.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceInfo.Sl iceStartAbs")
            >>TextBox4.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceInfo.L3 Filename")
            >>>
            >>TextBox5.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceRatings .RatingName")
            >>TextBox6.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceRatings .RatingValue")
            >>TextBox7.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceRatings .RatingName")
            >>TextBox8.Data Bindings.Add("T ext", DatasetInit,
            >>"SliceRatings .RatingValue")
            >>>
            >>Everything works great in the Datagrids. Datagrid1 shows the rows in
            >>the master/parent table Datagrid2 shows the child rows in the child
            >>table. In the text boxes, Textbox1 thru 4 are fine and as I step
            >>through the rows in Datagrid1, their value changes. Unfortunately,
            >>the values in the Textbox5 thru 8 do not change at all, leading me
            >>to believe that they are not somehow bound. Also, how do I make
            >>Textbox7 and 8 have the value from the second child row (right now
            >>it just repeats what is in textbox5 and 6 respectively)
            >>>
            >>Thanx for any help.
            >>>
            >>--
            >>Anil Gupte
            >>www.keeninc.net
            >>www.icinema.com
            >>>
            >>>
            >>"Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
            >>news:OXWUXT1G HHA.1216@TK2MSF TNGP05.phx.gbl. ..
            >>>Anil,
            >>>>
            >>>I give you only this link, I think that you can than go on.
            >>>>
            >>>http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
            >>>>
            >>>The missing link you have are the bad written parts about the
            >>>datarowsta te on MSDN.
            >>>>
            >>>Cor
            >>>>
            >>>"Anil Gupte" <anil-list@icinema.co mschreef in bericht
            >>>news:Oj9z1Bs GHHA.2456@TK2MS FTNGP06.phx.gbl ...
            >>>>After reading a tutorial and fiddling, I finally got this to work.
            >>>>I can now put two tables created with a DataTable class into a
            >>>>DataRelatio n. Phew! And it works!
            >>>>Dim tblSliceInfo As New DataTable("Slic eInfo")
            >>>>>
            >>>>Dim tblSliceRatings As New DataTable("Slic eRatings")
            >>>>>
            >>>>'.... All the adding datacolumns, datarows, etc. goes here..
            >>>>>
            >>>>DatasetInit .Tables.Add(tbl SliceInfo)
            >>>>>
            >>>>DatasetInit .Tables.Add(tbl SliceRatings)
            >>>>>
            >>>>Dim colSliceInfo As DataColumn
            >>>>>
            >>>>Dim colSliceRatings As DataColumn
            >>>>>
            >>>>colSliceInf o = tblSliceInfo.Co lumns("SliceID" )
            >>>>>
            >>>>colSliceRat ings = tblSliceRatings .Columns("Slice RatingsID")
            >>>>>
            >>>>Dim SliceIDRelation As DataRelation
            >>>>>
            >>>>SliceIDRela tion = New DataRelation("S liceIDRelation" ,
            >>>>colSliceInf o, colSliceRatings )
            >>>>>
            >>>>DatasetInit .Relations.Add( SliceIDRelation )
            >>>>>
            >>>>Anyway, what I want to do now is that instead of using those
            >>>>tables as above, I want to use a SQL statement so that I can
            >>>>select the correct records from the child table. How do I do
            >>>>this? I am planning to bind the values in the fields to textboxes
            >>>>and then allow editing of those.
            >>>>>
            >>>>Please give me a clue how to go about it.
            >>>>Thanx,
            >>>>--
            >>>>Anil Gupte
            >>>>www.keeninc.net
            >>>>www.icinema.com
            >>>>>
            >>>>>
            >>>>
            >>>>
            >>>
            >>>
            >>
            >>
            >
            >

            Comment

            • Anil Gupte

              #7
              Re: Data Relations with DataTable Class

              It *is* a DataTable and I am also using DataRow and DataColumn classes.
              This way, I do not have to send an mdb file along with my app. Of course I
              still created a Dataset using two DataTable objects.
              Dim tblSliceInfo As New DataTable("Slic eInfo")

              Dim tblSliceRatings As New DataTable("Slic eRatings")

              Dim DatasetInit As New DataSet

              DatasetInit.Tab les.Add(tblSlic eInfo)

              DatasetInit.Tab les.Add(tblSlic eRatings)

              Then the rest of the code I gave couple of messages ago.
              --
              Anil Gupte
              Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

              www.icinema.com

              "RobinS" <RobinS@NoSpam. yah.nonewrote in message
              news:P9idne5Aqq zLc-fYnZ2dnUVZ_qunn Z2d@comcast.com ...
              It's not a DataTable, it's a DataSet with multiple tables, right?
              >
              Assuming that's true, my code should work; just replace the parts
              where it fills the dataset by accessing the database with your
              parts where you populate the dataset. You can still using the
              BindingSource components to lubricate the process. After they
              have made changes, you can invoke the EndEdit method on the
              BindingSource to save the changes on the screen to the
              underlying DataSet.
              >
              If you were attached to a database, then after doing the EndEdit,
              you would invoke the Update method on the TableAdapter to
              cascade the changes down into the database. You won't have that
              part; you can save them however you want to after the DataTable
              is updated.
              >
              I don't know of a way to bind different rows in a datagrid to
              the textboxes, though. I've read a lot of material about data
              binding, and have never seen anything that will do that. So
              be sure to let us know if you find something like that. The
              only way I could think of is to load them manually as the user
              steps through the parent records, as noted below.
              >
              Good luck!
              >
              Robin S.
              --------------------------------------
              "Anil Gupte" <anil-list@icinema.co mwrote in message
              news:OYg6fl5GHH A.4688@TK2MSFTN GP04.phx.gbl...
              >Thanx, my main problem is trying to do this with a DataTable (in memory,
              >so there is no DataConnection object, and no physical database). I have
              >done it before with a MS Access DB. And I have done the Parent table
              >bindings succesfully in he current problem. It is just that I have not
              >been able to do the Child table bindings to text boxes. Basically, I
              >know that I need to find a DataRow, and then DataRow.ChildRo ws and then
              >bind Items(n) to each text box. I want to do databinding so I can write
              >just one simple update function and update my DataTable.
              >>
              >Thanx,
              >--
              >Anil Gupte
              >www.keeninc.net
              >www.icinema.com
              >>
              >"RobinS" <RobinS@NoSpam. yah.nonewrote in message
              >news:icednXfTv 6ek8-fYnZ2dnUVZ_siln Z2d@comcast.com ...
              >>This may help. You might want to check out the BindingSource
              >>component; using this for your databinding will more
              >>easily enable the parent/child binding. Here's an example;
              >>hopefully there will be something in here that you can use.
              >>>
              >>This example is for a form with two grids on it, and a bunch
              >>of textboxes. One grid is the parent, the other is the
              >>children, and the textboxes are bound to the parent.
              >>---------------------------
              >>>
              >>I have a dataset that has two tables: Customers and Orders.
              >>(This runs against Northwind, so if you have that
              >>installed, you can try this out.)
              >>>
              >>I set up a strongly-typed dataset using the Data Set
              >>Designer with both of those tables in it, and there is
              >>a field called CustomerID in the Orders table that links
              >>to the CustomerID table in Customers. So Orders have a
              >>Customer as a parent. The data relation between
              >>the customer and the orders is defined as FK_Orders_Custo mers.
              >>>
              >>(You can set up your dataset however you like.)
              >>>
              >>This is in Form_Load:
              >>>
              >> 'First, populate the dataset.
              >> Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
              >>>
              >> 'Set the data source for the binding source to the dataset.
              >> CustomersBindin gSource.DataSou rce = nwData
              >> 'Add this so it knows which table to use .
              >> CustomersBindin gSource.DataMem ber = "Customers"
              >> 'Set the data source for the grid to the customers binding source.
              >> CustomersDataGr idView.DataSour ce = CustomersBindin gSource
              >>>
              >> 'Add the binding for the child; set its binding source to the same
              >> ' one as the parent.
              >> Customers_Order sBindingSource. DataSource = CustomersBindin gSource
              >> 'Set the datamember to the foreign key joining the two tables.
              >> ' You can see this on your CustomersDataSe t diagram.
              >> Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
              >> 'Set the data source on the child grid to points at its
              >> ' binding source.
              >> OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
              >>>
              >> AddTextBoxDataB indings()
              >> AddComboBoxData Bindings()
              >>>
              >>Here are the routines that bind the textboxes and combo box
              >>in case you want them. These only bind to the Customers table,
              >>but you can easily bind textboxes to the children by binding
              >>to the Customers_Order sBindingSource instead of the
              >>CustomersBind ingSource.
              >>>
              >>Private Sub AddTextBoxDataB indings()
              >> 'Bind each text box to the appropriate field in the
              >> ' CustomersBindin gSource
              >> CustomerIDTextB ox.DataBindings .Add("Text", _
              >> CustomersBindin gSource, "CustomerID ")
              >> ContactNameText Box.DataBinding s.Add("Text", _
              >> CustomersBindin gSource, "ContactNam e")
              >> CompanyNameText Box.DataBinding s.Add("Text", _
              >> CustomersBindin gSource, "CompanyNam e")
              >> ContactPhoneTex tBox.DataBindin gs.Add("Text", _
              >> CustomersBindin gSource, "Phone")
              >>End Sub
              >>>
              >>Private Sub AddComboBoxData Bindings()
              >> ContactsComboBo x.DataSource = CustomersBindin gSource
              >> ContactsComboBo x.DisplayMember = "ContactNam e"
              >> ContactsComboBo x.ValueMember = "CustomerID "
              >>End Sub
              >>>
              >>This information came out of Brian Noyes's book on Data Binding.
              >>---------------------------
              >>>
              >>As for displaying info from specific rows in textboxes
              >>5 through 8, you could attach a handler to the positionChanged
              >>event on the binding source of the parents. In the event, you
              >>could check for multiple records in the children (probably
              >>using the binding source, maybe BindingSource.C ount?)
              >>and populate the textboxes accordingly.
              >>>
              >>Hope this helps.
              >>Robin S.
              >>-----------------------------
              >>"Anil Gupte" <anil-list@icinema.co mwrote in message
              >>news:e%23STCD 2GHHA.3780@TK2M SFTNGP02.phx.gb l...
              >>>Cor:
              >>>>
              >>>Thanx for your input. Unfrtunately, that example uses an access
              >>>database, but I am using a DataTable class, which I think will be more
              >>>secure, since people will not be able to get their hands on the data.
              >>>The problem I am having is this. If you see the code below:
              >>>DatasetInit. Tables.Add(tblS liceInfo) ' tblSliceInfo= "SliceInfo"
              >>>DatasetInit. Tables.Add(tblS liceRatings) ' tblSliceRatings =
              >>>"SliceRating s"
              >>>>
              >>>Dim colSliceInfo As DataColumn
              >>>Dim colSliceRatings As DataColumn
              >>>colSliceIn fo = tblSliceInfo.Co lumns("SliceID" )
              >>>colSliceRati ngs = tblSliceRatings .Columns("Slice RatingsID")
              >>>Dim SliceIDRelation As DataRelation
              >>>SliceIDRelat ion = New DataRelation("S liceIDRelation" , colSliceInfo,
              >>>colSliceRati ngs)
              >>>DatasetInit. Relations.Add(S liceIDRelation)
              >>>>
              >>>DataGrid1.Se tDataBinding(Da tasetInit, "SliceInfo" )
              >>>DataGrid2.Se tDataBinding(Da tasetInit, "SliceInfo.Slic eIdRelation")
              >>>>
              >>>TextBox1.Dat aBindings.Add(" Text", DatasetInit, "SliceInfo.Slic eID")
              >>>TextBox2.Dat aBindings.Add(" Text", DatasetInit, "SliceInfo.Slic eTitle")
              >>>TextBox3.Dat aBindings.Add(" Text", DatasetInit,
              >>>"SliceInfo.S liceStartAbs")
              >>>TextBox4.Dat aBindings.Add(" Text", DatasetInit, "SliceInfo.L3Fi lename")
              >>>>
              >>>TextBox5.Dat aBindings.Add(" Text", DatasetInit,
              >>>"SliceRating s.RatingName")
              >>>TextBox6.Dat aBindings.Add(" Text", DatasetInit,
              >>>"SliceRating s.RatingValue")
              >>>TextBox7.Dat aBindings.Add(" Text", DatasetInit,
              >>>"SliceRating s.RatingName")
              >>>TextBox8.Dat aBindings.Add(" Text", DatasetInit,
              >>>"SliceRating s.RatingValue")
              >>>>
              >>>Everything works great in the Datagrids. Datagrid1 shows the rows in
              >>>the master/parent table Datagrid2 shows the child rows in the child
              >>>table. In the text boxes, Textbox1 thru 4 are fine and as I step
              >>>through the rows in Datagrid1, their value changes. Unfortunately, the
              >>>values in the Textbox5 thru 8 do not change at all, leading me to
              >>>believe that they are not somehow bound. Also, how do I make Textbox7
              >>>and 8 have the value from the second child row (right now it just
              >>>repeats what is in textbox5 and 6 respectively)
              >>>>
              >>>Thanx for any help.
              >>>>
              >>>--
              >>>Anil Gupte
              >>>www.keeninc.net
              >>>www.icinema.com
              >>>>
              >>>>
              >>>"Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
              >>>news:OXWUXT1 GHHA.1216@TK2MS FTNGP05.phx.gbl ...
              >>>>Anil,
              >>>>>
              >>>>I give you only this link, I think that you can than go on.
              >>>>>
              >>>>http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
              >>>>>
              >>>>The missing link you have are the bad written parts about the
              >>>>datarowstat e on MSDN.
              >>>>>
              >>>>Cor
              >>>>>
              >>>>"Anil Gupte" <anil-list@icinema.co mschreef in bericht
              >>>>news:Oj9z1B sGHHA.2456@TK2M SFTNGP06.phx.gb l...
              >>>>>After reading a tutorial and fiddling, I finally got this to work. I
              >>>>>can now put two tables created with a DataTable class into a
              >>>>>DataRelati on. Phew! And it works!
              >>>>>Dim tblSliceInfo As New DataTable("Slic eInfo")
              >>>>>>
              >>>>>Dim tblSliceRatings As New DataTable("Slic eRatings")
              >>>>>>
              >>>>>'.... All the adding datacolumns, datarows, etc. goes here..
              >>>>>>
              >>>>>DatasetIni t.Tables.Add(tb lSliceInfo)
              >>>>>>
              >>>>>DatasetIni t.Tables.Add(tb lSliceRatings)
              >>>>>>
              >>>>>Dim colSliceInfo As DataColumn
              >>>>>>
              >>>>>Dim colSliceRatings As DataColumn
              >>>>>>
              >>>>>colSliceIn fo = tblSliceInfo.Co lumns("SliceID" )
              >>>>>>
              >>>>>colSliceRa tings = tblSliceRatings .Columns("Slice RatingsID")
              >>>>>>
              >>>>>Dim SliceIDRelation As DataRelation
              >>>>>>
              >>>>>SliceIDRel ation = New DataRelation("S liceIDRelation" , colSliceInfo,
              >>>>>colSliceRa tings)
              >>>>>>
              >>>>>DatasetIni t.Relations.Add (SliceIDRelatio n)
              >>>>>>
              >>>>>Anyway, what I want to do now is that instead of using those tables
              >>>>>as above, I want to use a SQL statement so that I can select the
              >>>>>correct records from the child table. How do I do this? I am
              >>>>>planning to bind the values in the fields to textboxes and then allow
              >>>>>editing of those.
              >>>>>>
              >>>>>Please give me a clue how to go about it.
              >>>>>Thanx,
              >>>>>--
              >>>>>Anil Gupte
              >>>>>www.keeninc.net
              >>>>>www.icinema.com
              >>>>>>
              >>>>>>
              >>>>>
              >>>>>
              >>>>
              >>>>
              >>>
              >>>
              >>
              >>
              >
              >

              Comment

              • RobinS

                #8
                Re: Data Relations with DataTable Class

                You have a DataSet with two DataTables in it.

                There is a DataRelation between the two tables.

                You have a grid showing the parents.

                You have a grid showing the children.

                You have some textboxes showing information from the
                currently selected parent.

                You have some textboxes showing information from multiple
                rows of the children for the currently selected parent.

                You want to know how to bind the textboxes showing
                information from the children rows for the currently
                selected parent.

                Is that right? Or am I completely not getting what
                you're asking?

                Robin S.
                -----------------------

                "Anil Gupte" <anil-list@icinema.co mwrote in message
                news:e2BgA27GHH A.4844@TK2MSFTN GP05.phx.gbl...
                It *is* a DataTable and I am also using DataRow and DataColumn
                classes. This way, I do not have to send an mdb file along with my
                app. Of course I still created a Dataset using two DataTable objects.
                Dim tblSliceInfo As New DataTable("Slic eInfo")
                >
                Dim tblSliceRatings As New DataTable("Slic eRatings")
                >
                Dim DatasetInit As New DataSet
                >
                DatasetInit.Tab les.Add(tblSlic eInfo)
                >
                DatasetInit.Tab les.Add(tblSlic eRatings)
                >
                Then the rest of the code I gave couple of messages ago.
                --
                Anil Gupte
                Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

                www.icinema.com
                >
                "RobinS" <RobinS@NoSpam. yah.nonewrote in message
                news:P9idne5Aqq zLc-fYnZ2dnUVZ_qunn Z2d@comcast.com ...
                >It's not a DataTable, it's a DataSet with multiple tables, right?
                >>
                >Assuming that's true, my code should work; just replace the parts
                >where it fills the dataset by accessing the database with your
                >parts where you populate the dataset. You can still using the
                >BindingSourc e components to lubricate the process. After they
                >have made changes, you can invoke the EndEdit method on the
                >BindingSourc e to save the changes on the screen to the
                >underlying DataSet.
                >>
                >If you were attached to a database, then after doing the EndEdit,
                >you would invoke the Update method on the TableAdapter to
                >cascade the changes down into the database. You won't have that
                >part; you can save them however you want to after the DataTable
                >is updated.
                >>
                >I don't know of a way to bind different rows in a datagrid to
                >the textboxes, though. I've read a lot of material about data
                >binding, and have never seen anything that will do that. So
                >be sure to let us know if you find something like that. The
                >only way I could think of is to load them manually as the user
                >steps through the parent records, as noted below.
                >>
                >Good luck!
                >>
                >Robin S.
                >--------------------------------------
                >"Anil Gupte" <anil-list@icinema.co mwrote in message
                >news:OYg6fl5GH HA.4688@TK2MSFT NGP04.phx.gbl.. .
                >>Thanx, my main problem is trying to do this with a DataTable (in
                >>memory, so there is no DataConnection object, and no physical
                >>database). I have done it before with a MS Access DB. And I have
                >>done the Parent table bindings succesfully in he current problem. It
                >>is just that I have not been able to do the Child table bindings to
                >>text boxes. Basically, I know that I need to find a DataRow, and
                >>then DataRow.ChildRo ws and then bind Items(n) to each text box. I
                >>want to do databinding so I can write just one simple update
                >>function and update my DataTable.
                >>>
                >>Thanx,
                >>--
                >>Anil Gupte
                >>www.keeninc.net
                >>www.icinema.com
                >>>
                >>"RobinS" <RobinS@NoSpam. yah.nonewrote in message
                >>news:icednXfT v6ek8-fYnZ2dnUVZ_siln Z2d@comcast.com ...
                >>>This may help. You might want to check out the BindingSource
                >>>component; using this for your databinding will more
                >>>easily enable the parent/child binding. Here's an example;
                >>>hopefully there will be something in here that you can use.
                >>>>
                >>>This example is for a form with two grids on it, and a bunch
                >>>of textboxes. One grid is the parent, the other is the
                >>>children, and the textboxes are bound to the parent.
                >>>---------------------------
                >>>>
                >>>I have a dataset that has two tables: Customers and Orders.
                >>>(This runs against Northwind, so if you have that
                >>>installed, you can try this out.)
                >>>>
                >>>I set up a strongly-typed dataset using the Data Set
                >>>Designer with both of those tables in it, and there is
                >>>a field called CustomerID in the Orders table that links
                >>>to the CustomerID table in Customers. So Orders have a
                >>>Customer as a parent. The data relation between
                >>>the customer and the orders is defined as FK_Orders_Custo mers.
                >>>>
                >>>(You can set up your dataset however you like.)
                >>>>
                >>>This is in Form_Load:
                >>>>
                >>> 'First, populate the dataset.
                >>> Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
                >>>>
                >>> 'Set the data source for the binding source to the dataset.
                >>> CustomersBindin gSource.DataSou rce = nwData
                >>> 'Add this so it knows which table to use .
                >>> CustomersBindin gSource.DataMem ber = "Customers"
                >>> 'Set the data source for the grid to the customers binding source.
                >>> CustomersDataGr idView.DataSour ce = CustomersBindin gSource
                >>>>
                >>> 'Add the binding for the child; set its binding source to the same
                >>> ' one as the parent.
                >>> Customers_Order sBindingSource. DataSource = CustomersBindin gSource
                >>> 'Set the datamember to the foreign key joining the two tables.
                >>> ' You can see this on your CustomersDataSe t diagram.
                >>> Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
                >>> 'Set the data source on the child grid to points at its
                >>> ' binding source.
                >>> OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
                >>>>
                >>> AddTextBoxDataB indings()
                >>> AddComboBoxData Bindings()
                >>>>
                >>>Here are the routines that bind the textboxes and combo box
                >>>in case you want them. These only bind to the Customers table,
                >>>but you can easily bind textboxes to the children by binding
                >>>to the Customers_Order sBindingSource instead of the
                >>>CustomersBin dingSource.
                >>>>
                >>>Private Sub AddTextBoxDataB indings()
                >>> 'Bind each text box to the appropriate field in the
                >>> ' CustomersBindin gSource
                >>> CustomerIDTextB ox.DataBindings .Add("Text", _
                >>> CustomersBindin gSource, "CustomerID ")
                >>> ContactNameText Box.DataBinding s.Add("Text", _
                >>> CustomersBindin gSource, "ContactNam e")
                >>> CompanyNameText Box.DataBinding s.Add("Text", _
                >>> CustomersBindin gSource, "CompanyNam e")
                >>> ContactPhoneTex tBox.DataBindin gs.Add("Text", _
                >>> CustomersBindin gSource, "Phone")
                >>>End Sub
                >>>>
                >>>Private Sub AddComboBoxData Bindings()
                >>> ContactsComboBo x.DataSource = CustomersBindin gSource
                >>> ContactsComboBo x.DisplayMember = "ContactNam e"
                >>> ContactsComboBo x.ValueMember = "CustomerID "
                >>>End Sub
                >>>>
                >>>This information came out of Brian Noyes's book on Data Binding.
                >>>---------------------------
                >>>>
                >>>As for displaying info from specific rows in textboxes
                >>>5 through 8, you could attach a handler to the positionChanged
                >>>event on the binding source of the parents. In the event, you
                >>>could check for multiple records in the children (probably
                >>>using the binding source, maybe BindingSource.C ount?)
                >>>and populate the textboxes accordingly.
                >>>>
                >>>Hope this helps.
                >>>Robin S.
                >>>-----------------------------
                >>>"Anil Gupte" <anil-list@icinema.co mwrote in message
                >>>news:e%23STC D2GHHA.3780@TK2 MSFTNGP02.phx.g bl...
                >>>>Cor:
                >>>>>
                >>>>Thanx for your input. Unfrtunately, that example uses an access
                >>>>database, but I am using a DataTable class, which I think will be
                >>>>more secure, since people will not be able to get their hands on
                >>>>the data. The problem I am having is this. If you see the code
                >>>>below:
                >>>>DatasetInit .Tables.Add(tbl SliceInfo) ' tblSliceInfo= "SliceInfo"
                >>>>DatasetInit .Tables.Add(tbl SliceRatings) ' tblSliceRatings =
                >>>>"SliceRatin gs"
                >>>>>
                >>>>Dim colSliceInfo As DataColumn
                >>>>Dim colSliceRatings As DataColumn
                >>>>colSliceInf o = tblSliceInfo.Co lumns("SliceID" )
                >>>>colSliceRat ings = tblSliceRatings .Columns("Slice RatingsID")
                >>>>Dim SliceIDRelation As DataRelation
                >>>>SliceIDRela tion = New DataRelation("S liceIDRelation" ,
                >>>>colSliceInf o, colSliceRatings )
                >>>>DatasetInit .Relations.Add( SliceIDRelation )
                >>>>>
                >>>>DataGrid1.S etDataBinding(D atasetInit, "SliceInfo" )
                >>>>DataGrid2.S etDataBinding(D atasetInit, "SliceInfo.Slic eIdRelation")
                >>>>>
                >>>>TextBox1.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceInfo. SliceID")
                >>>>TextBox2.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceInfo. SliceTitle")
                >>>>TextBox3.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceInfo. SliceStartAbs")
                >>>>TextBox4.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceInfo. L3Filename")
                >>>>>
                >>>>TextBox5.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceRatin gs.RatingName")
                >>>>TextBox6.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceRatin gs.RatingValue" )
                >>>>TextBox7.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceRatin gs.RatingName")
                >>>>TextBox8.Da taBindings.Add( "Text", DatasetInit,
                >>>>"SliceRatin gs.RatingValue" )
                >>>>>
                >>>>Everythin g works great in the Datagrids. Datagrid1 shows the rows
                >>>>in the master/parent table Datagrid2 shows the child rows in the
                >>>>child table. In the text boxes, Textbox1 thru 4 are fine and as I
                >>>>step through the rows in Datagrid1, their value changes.
                >>>>Unfortunate ly, the values in the Textbox5 thru 8 do not change at
                >>>>all, leading me to believe that they are not somehow bound. Also,
                >>>>how do I make Textbox7 and 8 have the value from the second child
                >>>>row (right now it just repeats what is in textbox5 and 6
                >>>>respectivel y)
                >>>>>
                >>>>Thanx for any help.
                >>>>>
                >>>>--
                >>>>Anil Gupte
                >>>>www.keeninc.net
                >>>>www.icinema.com
                >>>>>
                >>>>>
                >>>>"Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
                >>>>news:OXWUXT 1GHHA.1216@TK2M SFTNGP05.phx.gb l...
                >>>>>Anil,
                >>>>>>
                >>>>>I give you only this link, I think that you can than go on.
                >>>>>>
                >>>>>http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
                >>>>>>
                >>>>>The missing link you have are the bad written parts about the
                >>>>>datarowsta te on MSDN.
                >>>>>>
                >>>>>Cor
                >>>>>>
                >>>>>"Anil Gupte" <anil-list@icinema.co mschreef in bericht
                >>>>>news:Oj9z1 BsGHHA.2456@TK2 MSFTNGP06.phx.g bl...
                >>>>>>After reading a tutorial and fiddling, I finally got this to
                >>>>>>work. I can now put two tables created with a DataTable class
                >>>>>>into a DataRelation. Phew! And it works!
                >>>>>>Dim tblSliceInfo As New DataTable("Slic eInfo")
                >>>>>>>
                >>>>>>Dim tblSliceRatings As New DataTable("Slic eRatings")
                >>>>>>>
                >>>>>>'.... All the adding datacolumns, datarows, etc. goes here..
                >>>>>>>
                >>>>>>DatasetIn it.Tables.Add(t blSliceInfo)
                >>>>>>>
                >>>>>>DatasetIn it.Tables.Add(t blSliceRatings)
                >>>>>>>
                >>>>>>Dim colSliceInfo As DataColumn
                >>>>>>>
                >>>>>>Dim colSliceRatings As DataColumn
                >>>>>>>
                >>>>>>colSliceI nfo = tblSliceInfo.Co lumns("SliceID" )
                >>>>>>>
                >>>>>>colSliceR atings = tblSliceRatings .Columns("Slice RatingsID")
                >>>>>>>
                >>>>>>Dim SliceIDRelation As DataRelation
                >>>>>>>
                >>>>>>SliceIDRe lation = New DataRelation("S liceIDRelation" ,
                >>>>>>colSliceI nfo, colSliceRatings )
                >>>>>>>
                >>>>>>DatasetIn it.Relations.Ad d(SliceIDRelati on)
                >>>>>>>
                >>>>>>Anyway, what I want to do now is that instead of using those
                >>>>>>tables as above, I want to use a SQL statement so that I can
                >>>>>>select the correct records from the child table. How do I do
                >>>>>>this? I am planning to bind the values in the fields to
                >>>>>>textbox es and then allow editing of those.
                >>>>>>>
                >>>>>>Please give me a clue how to go about it.
                >>>>>>Thanx,
                >>>>>>--
                >>>>>>Anil Gupte
                >>>>>>www.keeninc.net
                >>>>>>www.icinema.com
                >>>>>>>
                >>>>>>>
                >>>>>>
                >>>>>>
                >>>>>
                >>>>>
                >>>>
                >>>>
                >>>
                >>>
                >>
                >>
                >
                >

                Comment

                • Anil Gupte

                  #9
                  Re: Data Relations with DataTable Class

                  Almost correct. One important thing is when I say DataTables, I am
                  referring to the Class System.Data.Dat aTable which is aparently derived from
                  System.Componen tModel.MarshalB yValueComponent

                  In other words, I did not create a DataConnection object or even a
                  DataAdapter object and there is no database - only the tables (out of thin
                  air). :-)

                  Also, the statement
                  You have some textboxes showing information from multiple
                  rows of the children for the currently selected parent.
                  si not entirely correct - I am able to show only the first row in the
                  textboxes (it just repeats), although I can see multiple rows in the
                  DataGrid bound to the child table.

                  Thanx for your patience.
                  --
                  Anil Gupte
                  Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

                  www.icinema.com

                  "RobinS" <RobinS@NoSpam. yah.nonewrote in message
                  news:cLidnX7W6_ VKmObYnZ2dnUVZ_ uC3nZ2d@comcast .com...
                  You have a DataSet with two DataTables in it.
                  >
                  There is a DataRelation between the two tables.
                  >
                  You have a grid showing the parents.
                  >
                  You have a grid showing the children.
                  >
                  You have some textboxes showing information from the
                  currently selected parent.
                  >
                  You have some textboxes showing information from multiple
                  rows of the children for the currently selected parent.
                  >
                  You want to know how to bind the textboxes showing
                  information from the children rows for the currently
                  selected parent.
                  >
                  Is that right? Or am I completely not getting what
                  you're asking?
                  >
                  Robin S.
                  -----------------------
                  >
                  "Anil Gupte" <anil-list@icinema.co mwrote in message
                  news:e2BgA27GHH A.4844@TK2MSFTN GP05.phx.gbl...
                  >It *is* a DataTable and I am also using DataRow and DataColumn classes.
                  >This way, I do not have to send an mdb file along with my app. Of course
                  >I still created a Dataset using two DataTable objects.
                  >Dim tblSliceInfo As New DataTable("Slic eInfo")
                  >>
                  >Dim tblSliceRatings As New DataTable("Slic eRatings")
                  >>
                  >Dim DatasetInit As New DataSet
                  >>
                  >DatasetInit.Ta bles.Add(tblSli ceInfo)
                  >>
                  >DatasetInit.Ta bles.Add(tblSli ceRatings)
                  >>
                  >Then the rest of the code I gave couple of messages ago.
                  >--
                  >Anil Gupte
                  >www.keeninc.net
                  >www.icinema.com
                  >>
                  >"RobinS" <RobinS@NoSpam. yah.nonewrote in message
                  >news:P9idne5Aq qzLc-fYnZ2dnUVZ_qunn Z2d@comcast.com ...
                  >>It's not a DataTable, it's a DataSet with multiple tables, right?
                  >>>
                  >>Assuming that's true, my code should work; just replace the parts
                  >>where it fills the dataset by accessing the database with your
                  >>parts where you populate the dataset. You can still using the
                  >>BindingSour ce components to lubricate the process. After they
                  >>have made changes, you can invoke the EndEdit method on the
                  >>BindingSour ce to save the changes on the screen to the
                  >>underlying DataSet.
                  >>>
                  >>If you were attached to a database, then after doing the EndEdit,
                  >>you would invoke the Update method on the TableAdapter to
                  >>cascade the changes down into the database. You won't have that
                  >>part; you can save them however you want to after the DataTable
                  >>is updated.
                  >>>
                  >>I don't know of a way to bind different rows in a datagrid to
                  >>the textboxes, though. I've read a lot of material about data
                  >>binding, and have never seen anything that will do that. So
                  >>be sure to let us know if you find something like that. The
                  >>only way I could think of is to load them manually as the user
                  >>steps through the parent records, as noted below.
                  >>>
                  >>Good luck!
                  >>>
                  >>Robin S.
                  >>--------------------------------------
                  >>"Anil Gupte" <anil-list@icinema.co mwrote in message
                  >>news:OYg6fl5G HHA.4688@TK2MSF TNGP04.phx.gbl. ..
                  >>>Thanx, my main problem is trying to do this with a DataTable (in
                  >>>memory, so there is no DataConnection object, and no physical
                  >>>database). I have done it before with a MS Access DB. And I have done
                  >>>the Parent table bindings succesfully in he current problem. It is just
                  >>>that I have not been able to do the Child table bindings to text boxes.
                  >>>Basically, I know that I need to find a DataRow, and then
                  >>>DataRow.Chil dRows and then bind Items(n) to each text box. I want to
                  >>>do databinding so I can write just one simple update function and
                  >>>update my DataTable.
                  >>>>
                  >>>Thanx,
                  >>>--
                  >>>Anil Gupte
                  >>>www.keeninc.net
                  >>>www.icinema.com
                  >>>>
                  >>>"RobinS" <RobinS@NoSpam. yah.nonewrote in message
                  >>>news:icednXf Tv6ek8-fYnZ2dnUVZ_siln Z2d@comcast.com ...
                  >>>>This may help. You might want to check out the BindingSource
                  >>>>component ; using this for your databinding will more
                  >>>>easily enable the parent/child binding. Here's an example;
                  >>>>hopefully there will be something in here that you can use.
                  >>>>>
                  >>>>This example is for a form with two grids on it, and a bunch
                  >>>>of textboxes. One grid is the parent, the other is the
                  >>>>children, and the textboxes are bound to the parent.
                  >>>>---------------------------
                  >>>>>
                  >>>>I have a dataset that has two tables: Customers and Orders.
                  >>>>(This runs against Northwind, so if you have that
                  >>>>installed , you can try this out.)
                  >>>>>
                  >>>>I set up a strongly-typed dataset using the Data Set
                  >>>>Designer with both of those tables in it, and there is
                  >>>>a field called CustomerID in the Orders table that links
                  >>>>to the CustomerID table in Customers. So Orders have a
                  >>>>Customer as a parent. The data relation between
                  >>>>the customer and the orders is defined as FK_Orders_Custo mers.
                  >>>>>
                  >>>>(You can set up your dataset however you like.)
                  >>>>>
                  >>>>This is in Form_Load:
                  >>>>>
                  >>>> 'First, populate the dataset.
                  >>>> Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
                  >>>>>
                  >>>> 'Set the data source for the binding source to the dataset.
                  >>>> CustomersBindin gSource.DataSou rce = nwData
                  >>>> 'Add this so it knows which table to use .
                  >>>> CustomersBindin gSource.DataMem ber = "Customers"
                  >>>> 'Set the data source for the grid to the customers binding source.
                  >>>> CustomersDataGr idView.DataSour ce = CustomersBindin gSource
                  >>>>>
                  >>>> 'Add the binding for the child; set its binding source to the same
                  >>>> ' one as the parent.
                  >>>> Customers_Order sBindingSource. DataSource = CustomersBindin gSource
                  >>>> 'Set the datamember to the foreign key joining the two tables.
                  >>>> ' You can see this on your CustomersDataSe t diagram.
                  >>>> Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
                  >>>> 'Set the data source on the child grid to points at its
                  >>>> ' binding source.
                  >>>> OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
                  >>>>>
                  >>>> AddTextBoxDataB indings()
                  >>>> AddComboBoxData Bindings()
                  >>>>>
                  >>>>Here are the routines that bind the textboxes and combo box
                  >>>>in case you want them. These only bind to the Customers table,
                  >>>>but you can easily bind textboxes to the children by binding
                  >>>>to the Customers_Order sBindingSource instead of the
                  >>>>CustomersBi ndingSource.
                  >>>>>
                  >>>>Private Sub AddTextBoxDataB indings()
                  >>>> 'Bind each text box to the appropriate field in the
                  >>>> ' CustomersBindin gSource
                  >>>> CustomerIDTextB ox.DataBindings .Add("Text", _
                  >>>> CustomersBindin gSource, "CustomerID ")
                  >>>> ContactNameText Box.DataBinding s.Add("Text", _
                  >>>> CustomersBindin gSource, "ContactNam e")
                  >>>> CompanyNameText Box.DataBinding s.Add("Text", _
                  >>>> CustomersBindin gSource, "CompanyNam e")
                  >>>> ContactPhoneTex tBox.DataBindin gs.Add("Text", _
                  >>>> CustomersBindin gSource, "Phone")
                  >>>>End Sub
                  >>>>>
                  >>>>Private Sub AddComboBoxData Bindings()
                  >>>> ContactsComboBo x.DataSource = CustomersBindin gSource
                  >>>> ContactsComboBo x.DisplayMember = "ContactNam e"
                  >>>> ContactsComboBo x.ValueMember = "CustomerID "
                  >>>>End Sub
                  >>>>>
                  >>>>This information came out of Brian Noyes's book on Data Binding.
                  >>>>---------------------------
                  >>>>>
                  >>>>As for displaying info from specific rows in textboxes
                  >>>>5 through 8, you could attach a handler to the positionChanged
                  >>>>event on the binding source of the parents. In the event, you
                  >>>>could check for multiple records in the children (probably
                  >>>>using the binding source, maybe BindingSource.C ount?)
                  >>>>and populate the textboxes accordingly.
                  >>>>>
                  >>>>Hope this helps.
                  >>>>Robin S.
                  >>>>-----------------------------
                  >>>>"Anil Gupte" <anil-list@icinema.co mwrote in message
                  >>>>news:e%23ST CD2GHHA.3780@TK 2MSFTNGP02.phx. gbl...
                  >>>>>Cor:
                  >>>>>>
                  >>>>>Thanx for your input. Unfrtunately, that example uses an access
                  >>>>>database , but I am using a DataTable class, which I think will be
                  >>>>>more secure, since people will not be able to get their hands on the
                  >>>>>data. The problem I am having is this. If you see the code below:
                  >>>>>DatasetIni t.Tables.Add(tb lSliceInfo) ' tblSliceInfo= "SliceInfo"
                  >>>>>DatasetIni t.Tables.Add(tb lSliceRatings) ' tblSliceRatings =
                  >>>>>"SliceRati ngs"
                  >>>>>>
                  >>>>>Dim colSliceInfo As DataColumn
                  >>>>>Dim colSliceRatings As DataColumn
                  >>>>>colSliceIn fo = tblSliceInfo.Co lumns("SliceID" )
                  >>>>>colSliceRa tings = tblSliceRatings .Columns("Slice RatingsID")
                  >>>>>Dim SliceIDRelation As DataRelation
                  >>>>>SliceIDRel ation = New DataRelation("S liceIDRelation" , colSliceInfo,
                  >>>>>colSliceRa tings)
                  >>>>>DatasetIni t.Relations.Add (SliceIDRelatio n)
                  >>>>>>
                  >>>>>DataGrid1. SetDataBinding( DatasetInit, "SliceInfo" )
                  >>>>>DataGrid2. SetDataBinding( DatasetInit, "SliceInfo.Slic eIdRelation")
                  >>>>>>
                  >>>>>TextBox1.D ataBindings.Add ("Text", DatasetInit, "SliceInfo.Slic eID")
                  >>>>>TextBox2.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceInfo .SliceTitle")
                  >>>>>TextBox3.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceInfo .SliceStartAbs" )
                  >>>>>TextBox4.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceInfo .L3Filename")
                  >>>>>>
                  >>>>>TextBox5.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceRati ngs.RatingName" )
                  >>>>>TextBox6.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceRati ngs.RatingValue ")
                  >>>>>TextBox7.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceRati ngs.RatingName" )
                  >>>>>TextBox8.D ataBindings.Add ("Text", DatasetInit,
                  >>>>>"SliceRati ngs.RatingValue ")
                  >>>>>>
                  >>>>>Everythi ng works great in the Datagrids. Datagrid1 shows the rows in
                  >>>>>the master/parent table Datagrid2 shows the child rows in the child
                  >>>>>table. In the text boxes, Textbox1 thru 4 are fine and as I step
                  >>>>>through the rows in Datagrid1, their value changes. Unfortunately,
                  >>>>>the values in the Textbox5 thru 8 do not change at all, leading me to
                  >>>>>believe that they are not somehow bound. Also, how do I make
                  >>>>>Textbox7 and 8 have the value from the second child row (right now it
                  >>>>>just repeats what is in textbox5 and 6 respectively)
                  >>>>>>
                  >>>>>Thanx for any help.
                  >>>>>>
                  >>>>>--
                  >>>>>Anil Gupte
                  >>>>>www.keeninc.net
                  >>>>>www.icinema.com
                  >>>>>>
                  >>>>>>
                  >>>>>"Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
                  >>>>>news:OXWUX T1GHHA.1216@TK2 MSFTNGP05.phx.g bl...
                  >>>>>>Anil,
                  >>>>>>>
                  >>>>>>I give you only this link, I think that you can than go on.
                  >>>>>>>
                  >>>>>>http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
                  >>>>>>>
                  >>>>>>The missing link you have are the bad written parts about the
                  >>>>>>datarowst ate on MSDN.
                  >>>>>>>
                  >>>>>>Cor
                  >>>>>>>
                  >>>>>>"Anil Gupte" <anil-list@icinema.co mschreef in bericht
                  >>>>>>news:Oj9z 1BsGHHA.2456@TK 2MSFTNGP06.phx. gbl...
                  >>>>>>>After reading a tutorial and fiddling, I finally got this to work.
                  >>>>>>>I can now put two tables created with a DataTable class into a
                  >>>>>>>DataRela tion. Phew! And it works!
                  >>>>>>>Dim tblSliceInfo As New DataTable("Slic eInfo")
                  >>>>>>>>
                  >>>>>>>Dim tblSliceRatings As New DataTable("Slic eRatings")
                  >>>>>>>>
                  >>>>>>>'.... All the adding datacolumns, datarows, etc. goes here..
                  >>>>>>>>
                  >>>>>>>DatasetI nit.Tables.Add( tblSliceInfo)
                  >>>>>>>>
                  >>>>>>>DatasetI nit.Tables.Add( tblSliceRatings )
                  >>>>>>>>
                  >>>>>>>Dim colSliceInfo As DataColumn
                  >>>>>>>>
                  >>>>>>>Dim colSliceRatings As DataColumn
                  >>>>>>>>
                  >>>>>>>colSlice Info = tblSliceInfo.Co lumns("SliceID" )
                  >>>>>>>>
                  >>>>>>>colSlice Ratings = tblSliceRatings .Columns("Slice RatingsID")
                  >>>>>>>>
                  >>>>>>>Dim SliceIDRelation As DataRelation
                  >>>>>>>>
                  >>>>>>>SliceIDR elation = New DataRelation("S liceIDRelation" , colSliceInfo,
                  >>>>>>>colSlice Ratings)
                  >>>>>>>>
                  >>>>>>>DatasetI nit.Relations.A dd(SliceIDRelat ion)
                  >>>>>>>>
                  >>>>>>>Anyway , what I want to do now is that instead of using those tables
                  >>>>>>>as above, I want to use a SQL statement so that I can select the
                  >>>>>>>correc t records from the child table. How do I do this? I am
                  >>>>>>>planni ng to bind the values in the fields to textboxes and then
                  >>>>>>>allow editing of those.
                  >>>>>>>>
                  >>>>>>>Please give me a clue how to go about it.
                  >>>>>>>Thanx,
                  >>>>>>>--
                  >>>>>>>Anil Gupte
                  >>>>>>>www.keeninc.net
                  >>>>>>>www.icinema.com
                  >>>>>>>>
                  >>>>>>>>
                  >>>>>>>
                  >>>>>>>
                  >>>>>>
                  >>>>>>
                  >>>>>
                  >>>>>
                  >>>>
                  >>>>
                  >>>
                  >>>
                  >>
                  >>
                  >
                  >

                  Comment

                  • RobinS

                    #10
                    Re: Data Relations with DataTable Class

                    Well, it doesn't matter *how* the datatables got created. My
                    code sample should still work for you. Just replace the data
                    source stuff (see my comments way down below, marked with **).

                    Again, I iterate that I don't know of any way to bind the
                    children textboxes to the specific rows of the grid. I would
                    add an event to the PositionChanged event of the parent,
                    and fill the 4 child textboxes accordingly in code.

                    Robin S.
                    -----------------------------

                    "Anil Gupte" <anil-list@icinema.co mwrote in message
                    news:eJk$TmVHHH A.320@TK2MSFTNG P06.phx.gbl...
                    Almost correct. One important thing is when I say DataTables, I am
                    referring to the Class System.Data.Dat aTable which is aparently
                    derived from System.Componen tModel.MarshalB yValueComponent
                    >
                    In other words, I did not create a DataConnection object or even a
                    DataAdapter object and there is no database - only the tables (out of
                    thin air). :-)
                    >
                    Also, the statement
                    >You have some textboxes showing information from multiple
                    >rows of the children for the currently selected parent.
                    >
                    si not entirely correct - I am able to show only the first row in the
                    textboxes (it just repeats), although I can see multiple rows in the
                    DataGrid bound to the child table.
                    >
                    Thanx for your patience.
                    --
                    Anil Gupte
                    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving

                    www.icinema.com
                    >
                    "RobinS" <RobinS@NoSpam. yah.nonewrote in message
                    news:cLidnX7W6_ VKmObYnZ2dnUVZ_ uC3nZ2d@comcast .com...
                    >You have a DataSet with two DataTables in it.
                    >>
                    >There is a DataRelation between the two tables.
                    >>
                    >You have a grid showing the parents.
                    >>
                    >You have a grid showing the children.
                    >>
                    >You have some textboxes showing information from the
                    >currently selected parent.
                    >>
                    >You have some textboxes showing information from multiple
                    >rows of the children for the currently selected parent.
                    >>
                    >You want to know how to bind the textboxes showing
                    >information from the children rows for the currently
                    >selected parent.
                    >>
                    >Is that right? Or am I completely not getting what
                    >you're asking?
                    >>
                    >Robin S.
                    >-----------------------
                    >>
                    >"Anil Gupte" <anil-list@icinema.co mwrote in message
                    >news:e2BgA27GH HA.4844@TK2MSFT NGP05.phx.gbl.. .
                    >>It *is* a DataTable and I am also using DataRow and DataColumn
                    >>classes. This way, I do not have to send an mdb file along with my
                    >>app. Of course I still created a Dataset using two DataTable
                    >>objects.
                    >>Dim tblSliceInfo As New DataTable("Slic eInfo")
                    >>>
                    >>Dim tblSliceRatings As New DataTable("Slic eRatings")
                    >>>
                    >>Dim DatasetInit As New DataSet
                    >>>
                    >>DatasetInit.T ables.Add(tblSl iceInfo)
                    >>>
                    >>DatasetInit.T ables.Add(tblSl iceRatings)
                    >>>
                    >>Then the rest of the code I gave couple of messages ago.
                    >>--
                    >>Anil Gupte
                    >>www.keeninc.net
                    >>www.icinema.com
                    >>>
                    >>"RobinS" <RobinS@NoSpam. yah.nonewrote in message
                    >>news:P9idne5A qqzLc-fYnZ2dnUVZ_qunn Z2d@comcast.com ...
                    >>>It's not a DataTable, it's a DataSet with multiple tables, right?
                    >>>>
                    >>>Assuming that's true, my code should work; just replace the parts
                    >>>where it fills the dataset by accessing the database with your
                    >>>parts where you populate the dataset. You can still using the
                    >>>BindingSourc e components to lubricate the process. After they
                    >>>have made changes, you can invoke the EndEdit method on the
                    >>>BindingSourc e to save the changes on the screen to the
                    >>>underlying DataSet.
                    >>>>
                    >>>If you were attached to a database, then after doing the EndEdit,
                    >>>you would invoke the Update method on the TableAdapter to
                    >>>cascade the changes down into the database. You won't have that
                    >>>part; you can save them however you want to after the DataTable
                    >>>is updated.
                    >>>>
                    >>>I don't know of a way to bind different rows in a datagrid to
                    >>>the textboxes, though. I've read a lot of material about data
                    >>>binding, and have never seen anything that will do that. So
                    >>>be sure to let us know if you find something like that. The
                    >>>only way I could think of is to load them manually as the user
                    >>>steps through the parent records, as noted below.
                    >>>>
                    >>>Good luck!
                    >>>>
                    >>>Robin S.
                    >>>--------------------------------------
                    >>>"Anil Gupte" <anil-list@icinema.co mwrote in message
                    >>>news:OYg6fl5 GHHA.4688@TK2MS FTNGP04.phx.gbl ...
                    >>>>Thanx, my main problem is trying to do this with a DataTable (in
                    >>>>memory, so there is no DataConnection object, and no physical
                    >>>>database) . I have done it before with a MS Access DB. And I have
                    >>>>done the Parent table bindings succesfully in he current problem.
                    >>>>It is just that I have not been able to do the Child table
                    >>>>bindings to text boxes. Basically, I know that I need to find a
                    >>>>DataRow, and then DataRow.ChildRo ws and then bind Items(n) to each
                    >>>>text box. I want to do databinding so I can write just one simple
                    >>>>update function and update my DataTable.
                    >>>>>
                    >>>>Thanx,
                    >>>>--
                    >>>>Anil Gupte
                    >>>>www.keeninc.net
                    >>>>www.icinema.com
                    >>>>>
                    >>>>"RobinS" <RobinS@NoSpam. yah.nonewrote in message
                    >>>>news:icednX fTv6ek8-fYnZ2dnUVZ_siln Z2d@comcast.com ...
                    >>>>>This may help. You might want to check out the BindingSource
                    >>>>>componen t; using this for your databinding will more
                    >>>>>easily enable the parent/child binding. Here's an example;
                    >>>>>hopefull y there will be something in here that you can use.
                    >>>>>>
                    >>>>>This example is for a form with two grids on it, and a bunch
                    >>>>>of textboxes. One grid is the parent, the other is the
                    >>>>>children , and the textboxes are bound to the parent.
                    >>>>>---------------------------
                    >>>>>>
                    >>>>>I have a dataset that has two tables: Customers and Orders.
                    >>>>>(This runs against Northwind, so if you have that
                    >>>>>installe d, you can try this out.)
                    >>>>>>
                    >>>>>I set up a strongly-typed dataset using the Data Set
                    >>>>>Designer with both of those tables in it, and there is
                    >>>>>a field called CustomerID in the Orders table that links
                    >>>>>to the CustomerID table in Customers. So Orders have a
                    >>>>>Customer as a parent. The data relation between
                    >>>>>the customer and the orders is defined as FK_Orders_Custo mers.
                    >>>>>>
                    >>>>>(You can set up your dataset however you like.)
                    >>>>>>
                    >>>>>This is in Form_Load:
                    >>>>>>
                    >>>>> 'First, populate the dataset.
                    >>>>> Dim nwData As CustomersDataSe t = CustomersDataSe t.GetCustomers( )
                    >>>>>>
                    >>>>> 'Set the data source for the binding source to the dataset.
                    **Set the parent DataSource to the name of your dataset
                    that has the two tables in it.
                    >>>>> CustomersBindin gSource.DataSou rce = nwData
                    >>>>> 'Add this so it knows which table to use .
                    **set this to the name of your parent table.
                    >>>>> CustomersBindin gSource.DataMem ber = "Customers"
                    >>>>> 'Set the data source for the grid to the customers binding
                    >>>>>source.
                    **this is the parent grid. Set it to the parent BindingSource.
                    >>>>> CustomersDataGr idView.DataSour ce = CustomersBindin gSource
                    >>>>>>
                    >>>>> 'Add the binding for the child; set its binding source to the
                    >>>>>same
                    >>>>> ' one as the parent.
                    **This is the datasource for the bindingsource for the children,
                    ** set to the binding source for the parents.
                    >>>>> Customers_Order sBindingSource. DataSource =
                    >>>>>CustomersB indingSource
                    >>>>> 'Set the datamember to the foreign key joining the two tables.
                    >>>>> ' You can see this on your CustomersDataSe t diagram.
                    **Set this to the data relation between the two tables.
                    >>>>> Customers_Order sBindingSource. DataMember = "FK_Orders_Cust omers"
                    >>>>> 'Set the data source on the child grid to points at its
                    >>>>> ' binding source.
                    **this is the grid for the children.
                    >>>>> OrdersDataGridV iew.DataSource = Customers_Order sBindingSource
                    >>>>>>
                    >>>>> AddTextBoxDataB indings()
                    >>>>> AddComboBoxData Bindings()
                    >>>>>>
                    >>>>>Here are the routines that bind the textboxes and combo box
                    >>>>>in case you want them. These only bind to the Customers table,
                    >>>>>but you can easily bind textboxes to the children by binding
                    >>>>>to the Customers_Order sBindingSource instead of the
                    >>>>>CustomersB indingSource.
                    >>>>>>
                    **this is how to bind textboxes to show data from the parent grid.
                    >>>>>Private Sub AddTextBoxDataB indings()
                    >>>>> 'Bind each text box to the appropriate field in the
                    >>>>> ' CustomersBindin gSource
                    >>>>> CustomerIDTextB ox.DataBindings .Add("Text", _
                    >>>>> CustomersBindin gSource, "CustomerID ")
                    >>>>> ContactNameText Box.DataBinding s.Add("Text", _
                    >>>>> CustomersBindin gSource, "ContactNam e")
                    >>>>> CompanyNameText Box.DataBinding s.Add("Text", _
                    >>>>> CustomersBindin gSource, "CompanyNam e")
                    >>>>> ContactPhoneTex tBox.DataBindin gs.Add("Text", _
                    >>>>> CustomersBindin gSource, "Phone")
                    >>>>>End Sub
                    >>>>>>
                    >>>>>Private Sub AddComboBoxData Bindings()
                    >>>>> ContactsComboBo x.DataSource = CustomersBindin gSource
                    >>>>> ContactsComboBo x.DisplayMember = "ContactNam e"
                    >>>>> ContactsComboBo x.ValueMember = "CustomerID "
                    >>>>>End Sub
                    >>>>>>
                    >>>>>This information came out of Brian Noyes's book on Data Binding.
                    >>>>>---------------------------
                    >>>>>>
                    **this still applies. I don't know of a way to bind to a
                    specific row in the grid. I would use this method to
                    fill the textboxes that show information from the children.
                    >>>>>As for displaying info from specific rows in textboxes
                    >>>>>5 through 8, you could attach a handler to the positionChanged
                    >>>>>event on the binding source of the parents. In the event, you
                    >>>>>could check for multiple records in the children (probably
                    >>>>>using the binding source, maybe BindingSource.C ount?)
                    >>>>>and populate the textboxes accordingly.
                    >>>>>>
                    >>>>>Hope this helps.
                    >>>>>Robin S.
                    >>>>>-----------------------------
                    >>>>>"Anil Gupte" <anil-list@icinema.co mwrote in message
                    >>>>>news:e%23S TCD2GHHA.3780@T K2MSFTNGP02.phx .gbl...
                    >>>>>>Cor:
                    >>>>>>>
                    >>>>>>Thanx for your input. Unfrtunately, that example uses an access
                    >>>>>>databas e, but I am using a DataTable class, which I think will
                    >>>>>>be more secure, since people will not be able to get their hands
                    >>>>>>on the data. The problem I am having is this. If you see the
                    >>>>>>code below:
                    >>>>>>DatasetIn it.Tables.Add(t blSliceInfo) ' tblSliceInfo= "SliceInfo"
                    >>>>>>DatasetIn it.Tables.Add(t blSliceRatings) ' tblSliceRatings =
                    >>>>>>"SliceRat ings"
                    >>>>>>>
                    >>>>>>Dim colSliceInfo As DataColumn
                    >>>>>>Dim colSliceRatings As DataColumn
                    >>>>>>colSliceI nfo = tblSliceInfo.Co lumns("SliceID" )
                    >>>>>>colSliceR atings = tblSliceRatings .Columns("Slice RatingsID")
                    >>>>>>Dim SliceIDRelation As DataRelation
                    >>>>>>SliceIDRe lation = New DataRelation("S liceIDRelation" ,
                    >>>>>>colSliceI nfo, colSliceRatings )
                    >>>>>>DatasetIn it.Relations.Ad d(SliceIDRelati on)
                    >>>>>>>
                    >>>>>>DataGrid1 .SetDataBinding (DatasetInit, "SliceInfo" )
                    >>>>>>DataGrid2 .SetDataBinding (DatasetInit,
                    >>>>>>"SliceInf o.SliceIdRelati on")
                    >>>>>>>
                    >>>>>>TextBox1. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceInf o.SliceID")
                    >>>>>>TextBox2. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceInf o.SliceTitle")
                    >>>>>>TextBox3. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceInf o.SliceStartAbs ")
                    >>>>>>TextBox4. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceInf o.L3Filename")
                    >>>>>>>
                    >>>>>>TextBox5. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceRat ings.RatingName ")
                    >>>>>>TextBox6. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceRat ings.RatingValu e")
                    >>>>>>TextBox7. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceRat ings.RatingName ")
                    >>>>>>TextBox8. DataBindings.Ad d("Text", DatasetInit,
                    >>>>>>"SliceRat ings.RatingValu e")
                    >>>>>>>
                    >>>>>>Everythin g works great in the Datagrids. Datagrid1 shows the
                    >>>>>>rows in the master/parent table Datagrid2 shows the child rows
                    >>>>>>in the child table. In the text boxes, Textbox1 thru 4 are fine
                    >>>>>>and as I step through the rows in Datagrid1, their value
                    >>>>>>changes . Unfortunately, the values in the Textbox5 thru 8 do not
                    >>>>>>change at all, leading me to believe that they are not somehow
                    >>>>>>bound. Also, how do I make Textbox7 and 8 have the value from
                    >>>>>>the second child row (right now it just repeats what is in
                    >>>>>>textbox 5 and 6 respectively)
                    >>>>>>>
                    >>>>>>Thanx for any help.
                    >>>>>>>
                    >>>>>>--
                    >>>>>>Anil Gupte
                    >>>>>>www.keeninc.net
                    >>>>>>www.icinema.com
                    >>>>>>>
                    >>>>>>>
                    >>>>>>"Cor Ligthert [MVP]" <notmyfirstname @planet.nlwrote in message
                    >>>>>>news:OXWU XT1GHHA.1216@TK 2MSFTNGP05.phx. gbl...
                    >>>>>>>Anil,
                    >>>>>>>>
                    >>>>>>>I give you only this link, I think that you can than go on.
                    >>>>>>>>
                    >>>>>>>http://msdn2.microsoft.com/en-us/lib...70(vs.80).aspx
                    >>>>>>>>
                    >>>>>>>The missing link you have are the bad written parts about the
                    >>>>>>>datarows tate on MSDN.
                    >>>>>>>>
                    >>>>>>>Cor
                    >>>>>>>>
                    >>>>>>>"Anil Gupte" <anil-list@icinema.co mschreef in bericht
                    >>>>>>>news:Oj9 z1BsGHHA.2456@T K2MSFTNGP06.phx .gbl...
                    >>>>>>>>After reading a tutorial and fiddling, I finally got this to
                    >>>>>>>>work. I can now put two tables created with a DataTable class
                    >>>>>>>>into a DataRelation. Phew! And it works!
                    >>>>>>>>Dim tblSliceInfo As New DataTable("Slic eInfo")
                    >>>>>>>>>
                    >>>>>>>>Dim tblSliceRatings As New DataTable("Slic eRatings")
                    >>>>>>>>>
                    >>>>>>>>'.... All the adding datacolumns, datarows, etc. goes here..
                    >>>>>>>>>
                    >>>>>>>>Dataset Init.Tables.Add (tblSliceInfo)
                    >>>>>>>>>
                    >>>>>>>>Dataset Init.Tables.Add (tblSliceRating s)
                    >>>>>>>>>
                    >>>>>>>>Dim colSliceInfo As DataColumn
                    >>>>>>>>>
                    >>>>>>>>Dim colSliceRatings As DataColumn
                    >>>>>>>>>
                    >>>>>>>>colSlic eInfo = tblSliceInfo.Co lumns("SliceID" )
                    >>>>>>>>>
                    >>>>>>>>colSlic eRatings = tblSliceRatings .Columns("Slice RatingsID")
                    >>>>>>>>>
                    >>>>>>>>Dim SliceIDRelation As DataRelation
                    >>>>>>>>>
                    >>>>>>>>SliceID Relation = New DataRelation("S liceIDRelation" ,
                    >>>>>>>>colSlic eInfo, colSliceRatings )
                    >>>>>>>>>
                    >>>>>>>>Dataset Init.Relations. Add(SliceIDRela tion)
                    >>>>>>>>>
                    >>>>>>>>Anywa y, what I want to do now is that instead of using those
                    >>>>>>>>table s as above, I want to use a SQL statement so that I can
                    >>>>>>>>selec t the correct records from the child table. How do I do
                    >>>>>>>>this? I am planning to bind the values in the fields to
                    >>>>>>>>textbox es and then allow editing of those.
                    >>>>>>>>>
                    >>>>>>>>Pleas e give me a clue how to go about it.
                    >>>>>>>>Thanx ,
                    >>>>>>>>--
                    >>>>>>>>Anil Gupte
                    >>>>>>>>www.keeninc.net
                    >>>>>>>>www.icinema.com
                    >>>>>>>>>
                    >>>>>>>>>
                    >>>>>>>>
                    >>>>>>>>
                    >>>>>>>
                    >>>>>>>
                    >>>>>>
                    >>>>>>
                    >>>>>
                    >>>>>
                    >>>>
                    >>>>
                    >>>
                    >>>
                    >>
                    >>
                    >
                    >

                    Comment

                    Working...