473,221 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

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(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.FillDataSet(strConnection, "table3", _
"select * from table3", False, "table3", dsData)
dsData = clsDBGEN.FillDataSet(strConnection, "table4", _
"select * from table4", False, "table4", dsData)
dsData = clsDBGEN.CreateRelationship("table1", "table2", _
stMasterKeyColumns, stDetailKeyColumns, "table1table2", dsData)
dsData = clsDBGEN.CreateRelationship("table1", "table3", _
stMasterKeyColumns, stDetailKeyColumns, "table1table3", dsData)
dsData = clsDBGEN.CreateRelationship("table1", "table4", _
stMasterKeyColumns, stDetailKeyColumns, "table1table4", dsData)
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")
txtStrNo.DataBindings.Add("text", dsDataSet,
"table1.table1table2.street_no")
End If
Next
For Each drDataRow As DataRow In dsDataSet.Tables("table3").Rows
If drDataRow("compid") = dCompid And drDataRow("entity_id") = _
txtId.Text Then
txtShpStreet.DataBindings.Add("text", dsDataSet,
"table1.table1table3.street")
txtShpStrNo.DataBindings.Add("text", dsDataSet,
"table1.table1table3.street_no")
End If
Next
txt1.DataBindings.Add("text", dsDataSet,
"table1.table1table4.field1")
txt2.DataBindings.Add("text", dsDataSet,
"table1.table1table4.field2")
Catch ex As Exception
HandleExceptions(ex)
MsgBox("Query caused no record to be retrieved",
MsgBoxStyle.Information)
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
bdRecordNavigator = BindingContext(dsDataSet, stDataSetTable)
bdRecordNavigator.EndCurrentEdit()
bdRecordNavigator.Position += 1
Catch ex As Exception
HandleExceptions(ex)
End Try
End Sub

Thanks for your help
Mar 25 '07 #1
0 1392

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Graham Blandford | last post by:
Hi all, Can anyone assist me? VB6er trying to delve into the world of .NET... I have inherited a poorly designed database (access).. that uses multi-column keys to determine parent-child...
12
by: VMI | last post by:
For some reason, the process of retrieving data (about 20 records) from an Access table that has 400K records to a dataTable is taking over 3 mins. to complete. Below is my code to connect to the...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
1
by: Johann Blake | last post by:
I have a dataset that contains a parent table and a child table. A DataRelation exists between the two. I was under the impression from reading the VS docs that when I filled the parent table, the...
0
by: Gareth Stretch | last post by:
Hi Guys. i am using C#.net connecting to an Access database using OleDbConnection i am using the following select Statement to join 3 tables string strdvds = "SELECT dvd.name,...
5
by: Robert Brown | last post by:
Hi All. I have a routine that checks a SQL Table for all records 3 months prior to a predetermined date, then I insert them into an Archive DB then delete those records from the original table....
2
by: abc my vclass | last post by:
I want to write a form control to lookup some tables fields from database, let users to select one record (or multi-select more records) under win-form environment for fill some fields of parent...
4
by: RG | last post by:
Wondering if anyone can suggest a solution to my dilemma. (VB6, ADO, Access 200). The situation: Because I had pre-existing data inquiry modules that relied on database records, as well as a...
3
by: IAuditor | last post by:
Access 2003, XP - I have a multi-table query that is losing data. 1 table is a lookup (Hierarchy), and the other 3 are virtual duplicates (all with a one-to-many relationship with the lookup) except...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.