multi table dataset and navigating between records

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ohad Weiss

    #1

    multi table dataset and navigating between records

    Hi all,

    I've once asked about that topic. but didn't get an answer.

    I have a dataset based on 4 tables, which have relation between them.
    The main table presented to the user on textboxes placed on the form, and
    the rest of the tables presented on textboxes placed on tabpages (tabpage
    for each table).
    Here is the code I use:


    Code:
    Function CraeteDataset(B yVal strConnection As String, ByVal stWhereClause As
    String) As DataSet
    Dim stMasterKeyColu mns() As String = {"compid", "customer_i d"}
    Dim stDetailKeyColu mns() As String = {"compid", "entity_id" }
    Try
    Dim dsData As New DataSet
    Dim stWhereClauseAd d As String
    Dim drDataRow As DataRow
    dsData = clsDBGEN.FillDa taSet(strConnec tion, "table1", _
    "select * from table1", False, "table1", dsData)
    dsData = clsDBGEN.FillDa taSet(strConnec tion, "table2", _
    "select * from table2", False, "table2", dsData)
    dsData = clsDBGEN.FillDa taSet(strConnec tion, "table3", _
    "select * from table3", False, "table3", dsData)
    dsData = clsDBGEN.FillDa taSet(strConnec tion, "table4", _
    "select * from table4", False, "table4", dsData)
    dsData = clsDBGEN.Create Relationship("t able1", "table2", _
    stMasterKeyColu mns, stDetailKeyColu mns, "table1tabl e2", dsData)
    dsData = clsDBGEN.Create Relationship("t able1", "table3", _
    stMasterKeyColu mns, stDetailKeyColu mns, "table1tabl e3", dsData)
    dsData = clsDBGEN.Create Relationship("t able1", "table4", _
    stMasterKeyColu mns, stDetailKeyColu mns, "table1tabl e4", dsData)
    Return dsData
    Catch ex As Exception
    HandleException s(ex)
    End Try
    End Function

    Private Sub FillHeader(ByRe f dsDataSet As DataSet)
    Try
    stDataSetTable = dsDataSet.Table s.Item("table1" ).ToString
    txtId.DataBindi ngs.Add(New Binding("text", dsDataSet,
    stDataSetTable & ".id"))
    txtName.DataBin dings.Add(New Binding("text", dsDataSet,
    stDataSetTable & ".name"))
    Catch ex As Exception
    HandleException s(ex)
    MsgBox("Query caused no record to be retrieved",
    MsgBoxStyle.Inf ormation)
    End Try
    End Sub

    Private Sub FillLines(ByRef dsDataSet As DataSet)
    Try
    For Each drDataRow As DataRow In dsDataSet.Table s("table2").Row s
    If drDataRow("comp id") = dCompid And drDataRow("enti ty_id") = _
    txtId.Text Then
    txtStreet.DataB indings.Add("te xt", dsDataSet,
    "table1.table1t able2.street")
    txtStrNo.DataBi ndings.Add("tex t", dsDataSet,
    "table1.table1t able2.street_no ")
    End If
    Next
    For Each drDataRow As DataRow In dsDataSet.Table s("table3").Row s
    If drDataRow("comp id") = dCompid And drDataRow("enti ty_id") = _
    txtId.Text Then
    txtShpStreet.Da taBindings.Add( "text", dsDataSet,
    "table1.table1t able3.street")
    txtShpStrNo.Dat aBindings.Add(" text", dsDataSet,
    "table1.table1t able3.street_no ")
    End If
    Next
    txt1.DataBindin gs.Add("text", dsDataSet,
    "table1.table1t able4.field1")
    txt2.DataBindin gs.Add("text", dsDataSet,
    "table1.table1t able4.field2")
    Catch ex As Exception
    HandleException s(ex)
    MsgBox("Query caused no record to be retrieved",
    MsgBoxStyle.Inf ormation)
    End Try
    End Sub



    When I query the dataset, each filed show the correct data. The same happens
    when I navigate between records
    When I change data in the main form, and then navigate between records, the
    changes are saved to the dataset. (as expected)
    When I change data in one of the tabpages and then navigate between records,
    the changes not save to the dataset.
    What do I miss here?

    Here is the code for navigating next for example:

    Code:
    Sub MoveNext(ByVal dsDataSet As DataSet, ByVal stDataSetTable As String)
    Try
    bdRecordNavigat or = BindingContext( dsDataSet, stDataSetTable)
    bdRecordNavigat or.EndCurrentEd it()
    bdRecordNavigat or.Position += 1
    Catch ex As Exception
    HandleException s(ex)
    End Try
    End Sub



    Thanks for your help


Working...