Hi
I have a problem with two textboxes binded to a dataset, based on paren
table, and table for the child records.
I can navigate between the master records (and of course the child records
are changed according to the datarelation), but when I try to add a new
record, and then try to navigate between master records, the child records
are noot changing.
Does anyone have a solution?
Here is the code I used:
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.Create Relationship("t able1", "table2", _
stMasterKeyColu mns, stDetailKeyColu mns, "table1tabl e2", dsData)
dsData = clsDBGEN.Create Relationship("t able1", "table3", _
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")
End If
Next
Catch ex As Exception
HandleException s(ex)
MsgBox("Query caused no record to be retrieved",
MsgBoxStyle.Inf ormation)
End Try
End Sub
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