473,761 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Binding sources question in Vs2005

Bob
I have noticed that as one adds related tables to a bindingsource and
dataset(vs2005 Vb.Net Sql Server 2005), the TODO and following code that
fills the datasets on form load are written to the formload event in the
order in which you drag the tables to the form to make a gridview, the last
table you drag is written to the top. Since you normallly start by dragging
the parent table and then the child tables and grandchild tables, what
happens is that the fill statements for the child tables get executed first
by default. The implication of this seems to be that the total contents of
the child tables get taken from the server (sql 2005 in my case) and that as
the parent record is changed by the user as he runs the form, a filter is
applied dynamically when you change the row to show only those records in
the child grids that are then pertinent, but the other unneeded records are
there taking up ressources in the background and going accross the network.

In systems with few records and on a fast LAN this is no problem. I'm
concerned however when the number of records goes up into the many
thousands, even millions. I had tested something with over 50000 patients or
customers in Vs2003 and found in VS 2003 at least this was the behaviour. It
was simple to test, you just executed a count on the table in the dataset
after it was filled and you saw that the result corresponded to the number
of records in the sql table. I found that forms designed with this behaviour
could take up to twenty seconds to load 50000 customer records and their
related info. The typical answer in this situation when I brought this up
was, thats the way ado works - use virtual mode datasets, but that in my
humble opinion is a poor substitute for really minimizing the number of
records to the ones you really need at a particular time and so minimizing
the transfer of info over the network and minimizing ressource useage on the
local machine. In 2003 we developped a dll that does this filtering and we
brought the load time down from 20 seconds to less than a second. We were
Using C1 data controls at the time but in Vs2005 we're not planning to use
those.

What I think is needed is the filling of the child datasets with filtered
neede info for that parent only downloaded from he server each time change
the selected parent is changed. In my case this would work since the
interface allows single row selection of the parent(s) only.

I would appreciate your comments on this situation and any suggestions on
how best to proceed and what pitfalls to look for when implementing this
type of approach, also of course if you think I'm totally off base, please
let me know. I may be trying to reinvent the wheel and if so I'd appreciate
knowing.

Thanks for your time.

Bob


Jan 17 '06 #1
2 1869
Hi,

"Bob" <bd*****@sgiims .com> wrote in message
news:OE******** *****@TK2MSFTNG P12.phx.gbl...
I have noticed that as one adds related tables to a bindingsource and
dataset(vs20 05 Vb.Net Sql Server 2005), the TODO and following code that
fills the datasets on form load are written to the formload event in the
order in which you drag the tables to the form to make a gridview, the last
table you drag is written to the top. Since you normallly start by dragging
the parent table and then the child tables and grandchild tables, what
happens is that the fill statements for the child tables get executed first
by default.
Even if the child table is loaded after the parent it will still load all
child rows and the child table should be loaded after the parent otherwise
you may get constraint errors saying that the parent row doesn't exist
(yet).
The implication of this seems to be that the total contents of the child
tables get taken from the server (sql 2005 in my case) and that as the
parent record is changed by the user as he runs the form, a filter is
applied dynamically when you change the row to show only those records in
the child grids that are then pertinent, but the other unneeded records are
there taking up ressources in the background
Yes, child rows that are potentially never seen are taking up memory.
and going accross the network.
Yes, but only once at form_load all rows would be loaded (parent & child).

In systems with few records and on a fast LAN this is no problem. I'm
concerned however when the number of records goes up into the many
thousands, even millions. I had tested something with over 50000 patients
or customers in Vs2003 and found in VS 2003 at least this was the
behaviour. It was simple to test, you just executed a count on the table
in the dataset after it was filled and you saw that the result
corresponded to the number of records in the sql table. I found that forms
designed with this behaviour could take up to twenty seconds to load 50000
customer records and their related info. The typical answer in this
situation when I brought this up was, thats the way ado works -
ADO.NET, true.
use virtual mode datasets, but that in my humble opinion is a poor
substitute for really minimizing the number of records to the ones you
really need at a particular time and so minimizing the transfer of info
over the network and minimizing ressource useage on the local machine. In
2003 we developped a dll that does this filtering and we brought the load
time down from 20 seconds to less than a second. We were Using C1 data
controls at the time but in Vs2005 we're not planning to use those.
Not sure what you mean with virtual mode dataset, virtual mode controls i
know, but afaik a bound DataGridView behaves pretty much as a virtual mode
control but eg. a ComboBox not.

What I think is needed is the filling of the child datasets with filtered
neede info for that parent only downloaded from he server each time change
the selected parent is changed. In my case this would work since the
interface allows single row selection of the parent(s) only.
You could implement this yourself, by adding a parameterized query to the
existing child TableAdapter with a fk parameter:

- Inside DataSet schema designer, right-click on the child TableAdapter and
choose "Add query", then make a query that returns the rows only for a
certain fk, eg.
SELECT * FROM child WHERE fk = @fk

The last step of the wizards will ask you for a Fill name, choose FillByFk
and finish wizard.

- Then attach an event to ParentBindingSo urce.CurrentCha nged and make it get
the child rows:
Private Sub ParentBindingSo urce_CurrentCha nged(...) Handles ....
Dim currentDRV As DataRowView = DirectCast( _
ParentBindingSo urce.Current, DataRowView)

ChildTableAdapt er.FillByFk(Som eDataSet.ChildT able, CInt(
curentDRV["pk"] ) )

End Sub

Note; in the above text and code you should replace pk & fk with the actual
pk & fk column names you have.

I would appreciate your comments on this situation and any suggestions on
how best to proceed and what pitfalls to look for when implementing this
In the above code above it looks like the child DataTable isn't cleared
before filling again, but be aware of the child TableAdapter on the Form, it
has a property "ClearBeforeFil l" which is true by default, but can be turned
off.

If you clear the child DataTable before filling it (again) then you must
first save the (previous) child rows otherwise you may loose changes. You
still have a choice whether you want to clear it or not (existing child rows
will be overwritten, at least if they also have a pk). Then there is
another option only load the child rows for a given parent once, but then
you'll need something to store 'for which parent rows the child rows are
already loaded', maybe an extra (dummy) boolean column in the parent
DataTable.

But because of the "lazy-loading", the UI may now freeze a little when you
browse parent rows when there are a lot of child rows for each parent. That
brings us to "asynchrono us" loading of both parent and child rows and in
case of 'loading child rows' abort when user moves to another parent,
unfortunetally there isn't much support for this.

HTH,
Greetings
type of approach, also of course if you think I'm totally off base, please
let me know. I may be trying to reinvent the wheel and if so I'd
appreciate knowing.

Thanks for your time.

Bob


Jan 17 '06 #2
Bob
Bart Thanks an awfull lot, your code snippets and how tp implement them will
go in my permanent reference library.
I really appreciate your insight,

Bob
"Bart Mermuys" <bm************ *@hotmail.com> wrote in message
news:uI******** ********@TK2MSF TNGP14.phx.gbl. ..
Hi,

"Bob" <bd*****@sgiims .com> wrote in message
news:OE******** *****@TK2MSFTNG P12.phx.gbl...
I have noticed that as one adds related tables to a bindingsource and
dataset(vs200 5 Vb.Net Sql Server 2005), the TODO and following code that
fills the datasets on form load are written to the formload event in the
order in which you drag the tables to the form to make a gridview, the
last table you drag is written to the top. Since you normallly start by
dragging the parent table and then the child tables and grandchild tables,
what happens is that the fill statements for the child tables get executed
first by default.


Even if the child table is loaded after the parent it will still load all
child rows and the child table should be loaded after the parent otherwise
you may get constraint errors saying that the parent row doesn't exist
(yet).
The implication of this seems to be that the total contents of the child
tables get taken from the server (sql 2005 in my case) and that as the
parent record is changed by the user as he runs the form, a filter is
applied dynamically when you change the row to show only those records in
the child grids that are then pertinent, but the other unneeded records
are there taking up ressources in the background


Yes, child rows that are potentially never seen are taking up memory.
and going accross the network.


Yes, but only once at form_load all rows would be loaded (parent & child).

In systems with few records and on a fast LAN this is no problem. I'm
concerned however when the number of records goes up into the many
thousands, even millions. I had tested something with over 50000 patients
or customers in Vs2003 and found in VS 2003 at least this was the
behaviour. It was simple to test, you just executed a count on the table
in the dataset after it was filled and you saw that the result
corresponded to the number of records in the sql table. I found that
forms designed with this behaviour could take up to twenty seconds to
load 50000 customer records and their related info. The typical answer in
this situation when I brought this up was, thats the way ado works -


ADO.NET, true.
use virtual mode datasets, but that in my humble opinion is a poor
substitute for really minimizing the number of records to the ones you
really need at a particular time and so minimizing the transfer of info
over the network and minimizing ressource useage on the local machine. In
2003 we developped a dll that does this filtering and we brought the load
time down from 20 seconds to less than a second. We were Using C1 data
controls at the time but in Vs2005 we're not planning to use those.


Not sure what you mean with virtual mode dataset, virtual mode controls i
know, but afaik a bound DataGridView behaves pretty much as a virtual mode
control but eg. a ComboBox not.

What I think is needed is the filling of the child datasets with filtered
neede info for that parent only downloaded from he server each time
change the selected parent is changed. In my case this would work since
the interface allows single row selection of the parent(s) only.


You could implement this yourself, by adding a parameterized query to the
existing child TableAdapter with a fk parameter:

- Inside DataSet schema designer, right-click on the child TableAdapter
and choose "Add query", then make a query that returns the rows only for a
certain fk, eg.
SELECT * FROM child WHERE fk = @fk

The last step of the wizards will ask you for a Fill name, choose FillByFk
and finish wizard.

- Then attach an event to ParentBindingSo urce.CurrentCha nged and make it
get the child rows:
Private Sub ParentBindingSo urce_CurrentCha nged(...) Handles ....
Dim currentDRV As DataRowView = DirectCast( _
ParentBindingSo urce.Current, DataRowView)

ChildTableAdapt er.FillByFk(Som eDataSet.ChildT able, CInt(
curentDRV["pk"] ) )

End Sub

Note; in the above text and code you should replace pk & fk with the
actual pk & fk column names you have.

I would appreciate your comments on this situation and any suggestions on
how best to proceed and what pitfalls to look for when implementing this


In the above code above it looks like the child DataTable isn't cleared
before filling again, but be aware of the child TableAdapter on the Form,
it has a property "ClearBeforeFil l" which is true by default, but can be
turned off.

If you clear the child DataTable before filling it (again) then you must
first save the (previous) child rows otherwise you may loose changes. You
still have a choice whether you want to clear it or not (existing child
rows will be overwritten, at least if they also have a pk). Then there is
another option only load the child rows for a given parent once, but then
you'll need something to store 'for which parent rows the child rows are
already loaded', maybe an extra (dummy) boolean column in the parent
DataTable.

But because of the "lazy-loading", the UI may now freeze a little when
you browse parent rows when there are a lot of child rows for each parent.
That brings us to "asynchrono us" loading of both parent and child rows and
in case of 'loading child rows' abort when user moves to another parent,
unfortunetally there isn't much support for this.

HTH,
Greetings
type of approach, also of course if you think I'm totally off base,
please let me know. I may be trying to reinvent the wheel and if so I'd
appreciate knowing.

Thanks for your time.

Bob



Jan 18 '06 #3

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

Similar topics

1
1090
by: erik.c.larson | last post by:
I imported a projected I created in VS2003 to VS2005 beta 2. The project builds just fine, but throws an ArgumentException (cannot bind property...) when I add a control to a Controls list. When I comment out all my simple data bindings obj.DataBindings.Add(property, dataSource, dataMember), it runs just fine, but without binding. Any ideas why this would work fine in VS2003 but not in VS2005?
0
1733
by: popsovy | last post by:
Hi I have a question about whether Data Binding can facilitate the process of saving data in a web application I learned that you can data bind information from a number of different data sources to controls such as TextBox, ListBox, etc. I am clear on the concept of data flowing from data sources into web forms controls What I am not clear about is how to make the data flow the other way. When I am ready to save the changes or add a...
1
2753
by: dbuchanan | last post by:
Hello, A section in Data Sources window is mystifying to me. In the case of my code the Data Sources window shows my references to the data access layer. First here is what I see in my Data Sources window ... ( means expandable, means expanded, is a checked checkbox, "QmsDataLayer" is the name of the referenced data layer.)
4
2056
by: emzyme20 | last post by:
Hi, I am trying to populate a list control that is bound to a data table but the display member needs to come from a different data table. I have two list controls in C#, one displaying available categories and one displaying selected categories. In the database these are represented in two tables, the available category table has an ID and a Name. The other table is a category links table that has an ID, Category_ID and a Book_ID.
0
2347
by: Steven Bolard | last post by:
Hello, I am trying to port my .net 1.1 application to 2.0. I am using vs2005. I am trying to get my webservices to run and although i can compile them and and get wsdl and service descriptions through internet explorer when hitting the ..asmx url, i cannot generate a proxy class to use in my winforms assembly. When i try to generate a proxy, i get no error message but nor do i get a reference.vb so there is no type info. If i then try...
10
1537
by: David Lee Conley | last post by:
When I open the Data Sources window and create a new data source, everything works fine. But if I have a form showing in the IDE, the Data Sources window becomes disabled and doesn't display any of the database components. Yet, when I switch to code view, I can see everything just fine. Does anyone have any idea why the Data Sources window becomes disabled when I'm viewing forms? TIA.
1
1501
by: Greg Collins [Microsoft MVP] | last post by:
I am starting a project where I will be using the XML data type in SQL Server 2005, and ASP.NET to display and update the content of the XML. I've been digging around for a bit trying to find some sources that will explain the process of doing data binding in ASP.NET with the SQL XML, but haven't been able to locate anything too useful yet. The XML will be charts, each holding 3 groups of 70 rows of data, each row having 5 fields (boolean,...
3
2445
by: Max | last post by:
Hello, I made a windows form with a combo box and 4 text boxes. All 5 objects should get their data from a data set which is populated in the form load method. The combo box has item ids. When the users selects an item from the combo box I'd like the 4 text boxes to get populated with the corresponding item information from the same dataset table row that the combo box is pulling it's info from. Is there an easy way of doing this besides...
4
2865
by: John Sheppard | last post by:
Hello there, I was wondering if anyone knew how to loop through all binding sources on a form? I tried the below code but the me.controls collection doesnt return everything :( For Each obj As Object In Me.Controls If TypeOf (obj) Is BindingSource Then
0
9377
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
10136
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...
0
8814
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
7358
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...
0
5266
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3913
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
3
3509
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2788
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.