473,857 Members | 2,017 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB2005: Simulate BindingSource Navigation of Parent - Child Table

nev
251 Contributor
I have placed fields on form using datadesigner. I have a parent, child and childchild table. When I navigate the parent, naturally the child and childchild follows. Due to certain requirements, I changed the bindings of the childchild fields to point to its true table. Of course, when I navigate the parent, the childchild fields will not follow anymore.

Now I place this code in the childbindingsou rce currentchanged event to let the childchild fields follow again...

dim drv as datarowview = directcast(chil dbindingsource. current, datarowview)
childchildbindi ngsource.filter = "PrimaryKey = '" & drv("ForeignKey ") & ""'"

My problem is when I navigate the parent and it has no corresponding child data. The child fields follow the parent and will of course be blank just like EndOfFile. But what will I do to the childchildbindi ngsource so that the childchild fields will also be blank and point to the EndOfFile?

Hoping anyone can enlighten me.
Nov 7 '07 #1
6 3226
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
I have placed fields on form using datadesigner. I have a parent, child and childchild table. When I navigate the parent, naturally the child and childchild follows. Due to certain requirements, I changed the bindings of the childchild fields to point to its true table. Of course, when I navigate the parent, the childchild fields will not follow anymore.

Now I place this code in the childbindingsou rce currentchanged event to let the childchild fields follow again...

dim drv as datarowview = directcast(chil dbindingsource. current, datarowview)
childchildbindi ngsource.filter = "PrimaryKey = '" & drv("ForeignKey ") & ""'"

My problem is when I navigate the parent and it has no corresponding child data. The child fields follow the parent and will of course be blank just like EndOfFile. But what will I do to the childchildbindi ngsource so that the childchild fields will also be blank and point to the EndOfFile?

Hoping anyone can enlighten me.
Lets see how well i understood this.
You have a parent datatable, whever you navigate it, then the data in another datatable being displayed is changed due to the cange in the parent table navigation.
Now if this does not exist or the parent does not have data, your child table still shows it.

something like that i believe.

What i did was to find if there is data in the parent table, or if (corresponding data could be found, if not clear the table)

does that help anyways?

probably a smaller example of a parent and a child table o f your explanation can make it clearer.

cheers
Nov 7 '07 #2
nev
251 Contributor
Lets see how well i understood this.
You have a parent datatable, whever you navigate it, then the data in another datatable being displayed is changed due to the cange in the parent table navigation.
Now if this does not exist or the parent does not have data, your child table still shows it.

something like that i believe.

What i did was to find if there is data in the parent table, or if (corresponding data could be found, if not clear the table)

does that help anyways?

probably a smaller example of a parent and a child table o f your explanation can make it clearer.

cheers
Well, you've almost got it. Thing is I used 3 tables in my previous example because it nearly reflects what I'm really doing. And I use the bindingsource to navigate.

I got Table1 --(parent of)--> Table2 --(parent of)--> Table3

After using the datadesigner to drag n drop the fields from the datasources pane to my form, I can navigate Table1... Table2 and Table3 follows.

Note: If I navigate Table1 and Table2 has no data, then Table3 will not display data also because it is connected to Table2.

Then, I need to change the bindings of Table3 to point it to its true table due to certain requirements.

When I navigate Table1, only Table2 follows. So I did the code in my previous post to make Table3 follow programatically .

The problem is (see note above), If I navigate Table1 and Table2 has no data, I do not know what I should do to the Table3 bindingsource to make it blank like Table2.

I tried Table3bindingso urce.Filter = "PrimaryKey ='" & directcast(Tabl e2bindingsource .current, datarowview)("F oreignKey") & "'"

or Table3bindingso urce.position = -1

or dumber Table3bindingso urce.EOF = True

ERROR!
Nov 7 '07 #3
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
ok,
so you should be using the position changed event of the navigators to accomplish this.
on the change evnd of the 2nd tables navigator, check if there is any data, using bindingNavigato r.Count.
if this value is zero then clear the dataTable

using dataTable.Clear

cheers
This is how I do it, a little learning is needed to make it as flawless as possible
Nov 7 '07 #4
nev
251 Contributor
ok,
so you should be using the position changed event of the navigators to accomplish this.
on the change evnd of the 2nd tables navigator, check if there is any data, using bindingNavigato r.Count.
if this value is zero then clear the dataTable

using dataTable.Clear

cheers
This is how I do it, a little learning is needed to make it as flawless as possible
Based on your suggestion, I have tried this code just to check it out:

In Table2bindingso urce currentchanged event

if Table2bindingso urce.count > 0 then
msgbox("Greater ")
else
msgbox("Less or Equal")
end if

When I navigate Table1 and Table2 has data, no problem. But when I encounter a Table2 without data, errorhandler fires even before my messagebox "Less or Equal" displays. Can I do this without having to modify the errorhandler? The problem lies in the 'else' statement.
Nov 7 '07 #5
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Based on your suggestion, I have tried this code just to check it out:

In Table2bindingso urce currentchanged event

if Table2bindingso urce.count > 0 then
msgbox("Greater ")
else
msgbox("Less or Equal")
end if

When I navigate Table1 and Table2 has data, no problem. But when I encounter a Table2 without data, errorhandler fires even before my messagebox "Less or Equal" displays. Can I do this without having to modify the errorhandler? The problem lies in the 'else' statement.
instead of the msgbox of les or equal, clear data from table 3. using the Clear method of it.
Nov 7 '07 #6
nev
251 Contributor
instead of the msgbox of les or equal, clear data from table 3. using the Clear method of it.
Ok. I tried

Dataset.Table3d atatable... ---> There is no clear method here so I tried...

Table3bindingso urce.clear

ERROR! The statement Table3bindingso urce.clear becomes highlighted in green.
Nov 7 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2071
by: ebobnar | last post by:
I'm having trouble navigating my directory structure using php's ftp functions (such as ftp_chdir and ftp_cdup.) I'm writing a program that allows a user to easily create robot.txt files and upload them to their server. They should be able to log in to their server using ftp and browse their directory structure, specifying which robots to allow into each directory. When the user logs into their server, they are presented with a list of...
1
9128
by: ahaideb | last post by:
I have a table (relation) in my database: --------------- | parent | child | --------------- | 1 | 2 | | 1 | 3 | | 2 | 4 | | 2 | 5 | | 3 | 6 |
1
1642
by: Chris Fairman | last post by:
NG, I have a Dataset with multiple tables and relations defined. Currently when displaying a table from this Dataset in a DataGrid a hyper-link to the child rows is displayed. After clicking on the hyper-link, all the data in the DataGrid is 'removed' and replaced with only the parent row, and the child rows. I'm able to navigate back fort between Parent and child records without problems. However, this seems a bit clumsy.
2
987
by: DC | last post by:
Hi there, I've a datagrid with a parent-child navigation system. Data grid is bound to an Arraylist. My questions are: 1) On the parent info area, it shows "Arraylist" word and some info about parent. Can I remove "ArrayList" word? 2) When I click the plus sign (+), it creates a new child row with some name presented as an hiperlink. Can I change this name? Thanks in advance,
3
3940
by: silesius | last post by:
Hi All, I have two pagetabs. One pagetab is used to display a parent record and the other is suppose to display 3 related child records from another table. I can display the parent records just fine by using the bindingSource and a tableAdapter to fill the dataset. I'm having a problem displaying the 3 related records on the other pagetab. I can only bind to one record and have the bindingsource populate one set of databound contorls. I...
1
12201
by: Leonardo | last post by:
Hi. I'm trying to build my first application with database access using VB 2005. I'm a VB 6 programmer and learning everything again has been challenging. I managed to write a code using some tips from a book I recently bought. The navigation works fine. My problem starts when it comes to adding new registers. I have three tables: clients, addresses and telephones, so the client can have multiple address and telephones. The client data is...
3
5824
by: Troy Bull | last post by:
Greetings I have a simple application 2 tables related via foreign key. Table 1 Parts, table 2 Clients. ClientID is the primary key in the Client Table, clientID is a foreign key in the Parts table. I have a simple form that displays "parts" rows one at a time. I want to do the following on my partsBindingSource partsBindingSource.Filter = "client_id in (select clientId from clients where (name like 'KI%'))";
7
4988
by: Edwin Martinez | last post by:
Hello I have a parent form but I want to create 4 forms that will be shown in a area inside the parent form when I click to buttons. +----------------------------+ | Parent Form | | | | -------------------- | | | subform | | | | | | | | | |
2
4513
by: jehugaleahsa | last post by:
Hello: I'm working on improving some of our Windows Forms. I have created two user controls that I want to bind to the same BindingSource. I have an overview control that is used just to identify a customer. Then there is a details view that shows all their specifics. I wanted to keep navigation outside of my view. There is also a
0
9767
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11081
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10806
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10394
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9544
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7939
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4189
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3214
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.