469,644 Members | 1,681 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,644 developers. It's quick & easy.

textboxes databinding and navigating

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(ByVal strConnection As String, ByVal stWhereClause As
String) As DataSet
Dim stMasterKeyColumns() As String = {"compid", "customer_id"}
Dim stDetailKeyColumns() As String = {"compid", "entity_id"}
Try
Dim dsData As New DataSet
Dim stWhereClauseAdd As String
Dim drDataRow As DataRow
dsData = clsDBGEN.FillDataSet(strConnection, "table1", _
"select * from table1", False, "table1", dsData)
dsData = clsDBGEN.FillDataSet(strConnection, "table2", _
"select * from table2", False, "table2", dsData)
dsData = clsDBGEN.CreateRelationship("table1", "table2", _
stMasterKeyColumns, stDetailKeyColumns, "table1table2", dsData)
dsData = clsDBGEN.CreateRelationship("table1", "table3", _
Return dsData
Catch ex As Exception
HandleExceptions(ex)
End Try
End Function

Private Sub FillHeader(ByRef dsDataSet As DataSet)
Try
stDataSetTable = dsDataSet.Tables.Item("table1").ToString
txtId.DataBindings.Add(New Binding("text", dsDataSet,
stDataSetTable & ".id"))
txtName.DataBindings.Add(New Binding("text", dsDataSet,
stDataSetTable & ".name"))
Catch ex As Exception
HandleExceptions(ex)
MsgBox("Query caused no record to be retrieved",
MsgBoxStyle.Information)
End Try
End Sub

Private Sub FillLines(ByRef dsDataSet As DataSet)
Try
For Each drDataRow As DataRow In dsDataSet.Tables("table2").Rows
If drDataRow("compid") = dCompid And drDataRow("entity_id") = _
txtId.Text Then
txtStreet.DataBindings.Add("text", dsDataSet,
"table1.table1table2.street")
End If
Next
Catch ex As Exception
HandleExceptions(ex)
MsgBox("Query caused no record to be retrieved",
MsgBoxStyle.Information)
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
bdRecordNavigator = BindingContext(dsDataSet, stDataSetTable)
bdRecordNavigator.EndCurrentEdit()
bdRecordNavigator.Position += 1
Catch ex As Exception
HandleExceptions(ex)
End Try
End Sub

Mar 30 '07 #1
0 1044

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by Mike | last post: by
8 posts views Thread by stephen.clancy | last post: by
11 posts views Thread by John J. Hughes II | last post: by
5 posts views Thread by Patrick | last post: by
reply views Thread by Chris | last post: by
7 posts views Thread by =?Utf-8?B?Sm9lIFRob21wc29u?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.