473,386 Members | 1,757 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,386 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 1402

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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.