Solved

Why is there a TDataSouce?

Posted on 2000-03-24
14
162 Views
Last Modified: 2010-04-04
Something which has puzzled me ever since Delphi first came out:

What is the reason for having a DataSource class?

It seems to me data data-aware components and other users of datasets might just refer directly to the dataset in question. What is gained by having a DataSource in between?

Has anyone seen the light, or perhaps talked to someone from Borland/Inprise/Corell/(I wonder what comes next) about it?

Just curious...

Regards,
AndersWP

0
Comment
Question by:AndersWP
  • 3
  • 3
  • 2
  • +5
14 Comments
 
LVL 9

Expert Comment

by:ITugay
ID: 2652649
???
TDataSource provides an interface between a dataset component and data-aware controls on a form.

0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 2652674
hi all,

just from the delphi online help:

Description

Use TDataSource to provide a conduit between a dataset and data-aware controls on a form that enable display, navigation, and editing of the data underlying the dataset.

All datasets must be associated with a data source component if their data is to be displayed and manipulated in data-aware controls. Similarly, each data-aware control needs to be associated with a data source component in order for the control to receive and manipulate data.

Data source components also link datasets in master-detail relationships.

meikl
0
 
LVL 2

Expert Comment

by:florisb
ID: 2652699
pratical; you can use one datasource and have serveral queries using it. Otherwise there would be overhead.

Floris.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2652742
Hi all,

It seems to me the essence of a question is not in what does a DataSource, but why it exists (it is possible to build Delphi without it).

In my opinion, it is very convenient to separate visible controls from an actually source of data. I frequently make the forms which do not contain DataSet but only DataSorce. And it very simply to attach in runtime all of DataAwareControls to an actually source of the data.

Cheers,
Igor.
0
 
LVL 1

Author Comment

by:AndersWP
ID: 2652771
Well, guys (I presume), the points you bring up are of course all correct, but I still do not think they answer the question.

So let me put it another way:

Suppose for a moment that there was no TDataSource class in VCL, and that data-aware components and other dataset users in stead of the present DataSource property had a DataSet property. What would be lost in functionality/flexibility/...?

In other words, would we miss it, and conversely, what is the justification for introducing it?

Just for completeness, let's look at the issues you raise:

ITUgay and kretzschmar (DataSources are necessary glue between DataSets and data-aware components):
This seems like an insufficient argument to me. DataSources are necessary because VCL defines them so. This does not explain why VCL defines them as necessary.
 
florisb (Practical, multiple users per dataset):
Again, the same thing is readily achieved without the DataSource class. In fact, you can have several DataSources connected to each DataSet.

So, what do you say? Am I mistaken?

Regards,
AndersWP
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2652923
Hmmm.....
I never reflected in its necessity, and simply used. Probably it is any vestige (but convenient) of the past.

Cheers,
Igor.
0
 

Expert Comment

by:johnstoned
ID: 2653378
A possible use would be in this scenario.

You have a table, dataset and grid.

You want to use the program to update the table whilst the grid is disconnected.  To do this you just disable the dataset.  If you didn't have a dataset you would have to disable the table to turn the grid off, then wouldn't be able to update the table.

This is a really poor excuse as you could just use 2 tables to achieve this, but it is a possible explanation.

Dave.
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Author Comment

by:AndersWP
ID: 2653560
I guess in the scenario you describe you could also use the DisableControls/EnableControls methods of the DataSet to do what you describe (and by the way, I guess you really mean DataSource when you write DataSet).

Regards,
AndersWP
0
 
LVL 2

Expert Comment

by:kotik
ID: 2654059
For example, you can have many controls attached to one DataSource and more than one table (DataSet). If you want to display data from different tables the same way, you can simply change the DataSource.DataSet property and all controls will refresh displayed data.
Without DataSource you would have to change DataSet property of every control.

Another example you can get in Delphi Demos: look at the MastApp. You can see there the using a DataSource you can have 1 Navigator on your form and use it to manipulate data from different DataSets, f.e. Master - Detail.

Regards,
Kot.
0
 

Expert Comment

by:chumba
ID: 2654216
I'm not sure we can give you a definitive answer to satisfy your curiosity, since none of us were originally part of the design team for Delphi.  It is probably quite possible to build a language without the datasource class, BUT you would also find yourself writing code to perform the exact functions which this class provides; e.g.  provide the link between the data stored in the tables, and the data displayed to the user.  I tend to think in layers of software....so, this datasource 'layer' would have to be duplicated in every dataaccess or datacontrol component.  Hence, my GUESS is that the authors of Delphi created  the datasource layer to provide a convenient way to segment the functions performed by each class [i.e. dataaccess and datacontrol].
0
 
LVL 21

Expert Comment

by:gemarti
ID: 2654831
Simple: While designing an application it is nice to see data in your data aware components, so you set the datasource property in the control to see the live data.
0
 
LVL 21

Expert Comment

by:gemarti
ID: 2660579
.....otherwise, you don't need the TDataSource Component.........
0
 
LVL 1

Author Comment

by:AndersWP
ID: 2663228
I guess we have come as far as we are going to get on this question.

My conclusion of the discusstion would be that in some circumstances (many dataware components looking at one datasource, the concrecte datasource varies at runtime), the DataSource is useful. Otherwise, it is mostly decorative.

This question was not intended as a point-earning excercise, but never the less, there is the formidable amount of *10* points to be gained. I have drawn lots between the participants, and the lucky winner is...(suspense)... chumba.

Thanks guys for sharing your views on the subject.

Regards,
AndersWP
0
 

Accepted Solution

by:
chumba earned 10 total points
ID: 2664028
THANKS for the points, I could sure use them....almost have enough now to ask a half-decent difficult question.  Co-incidentally, I asked myself this same question a few months ago, but did not know of this forum.  Anyhow, I'll take the points, with thanks, anytime, even if it is by luck of the draw. ..I guess I'll now go and buy a lottery ticket. ;)
chumba
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now