Microsoft Access, ADO and One-to-Many relationship Delphi 2009

Microsoft Access

I have an Access database with 2 tables:

LakeMaps Table 1
LakeID: AutoNumber
Name: Text
County: Text
Town: Text
 Area: Number
 MaximumDepth: Number
 MeanDepth: Number
 MapFilename: Number

Species Table 2
Species: Text
SpeciesID: Number

LakeID is linked to SpeciesID in a One-To-Many relationship

In Microsoft Access a form shows the lake information and species 
information in each lake correctly.


Delphi 2009

A Delphi 2009 application with a TADOConnection, 2 TDataSource with 2 
TADODatasets and 2 DBGrids
ADOConnection1 the TADOConnection.ConnectionString points to the mdb file.

LakeSource.DataSet is LakeMaps
DBGrid1.DataSource is LakeSource
SpeciesSource.Dataset is Species
LakeMaps TADODataset has a CommandText of Shape {select * from Lakemaps}
Species TAdoDataSet.CommandText is blank
DBGrid2.DataSource is SpeciesSource

The lake database is displayed correctly in the DBGrid1
The species for each lake is empty in  DBGrid2.

This is similar to the ADO Shapes Demo.

1. What else to I have to add to the LakeMaps TADODataset.CommandText so 
that the species in each lake appears in DBGrid2?
2. Where can I find information about TADODataset.CommandText?  A search of 
the internet does not provide much info.

Regards,

Bill
0
Bill
1/28/2009 10:25:17 PM
embarcadero.delphi.database 1294 articles. 0 followers. Follow

4 Replies
663 Views

Similar Articles

[PageSpeed] 26

> {quote:title=Bill Miller wrote:}{quote}
> Microsoft Access
> 
> I have an Access database with 2 tables:

Bill, 

I assume you have the correct Source assigned to the DBGrid2.

Also you need to have linked the 1-to-many in the Access Relationships. 

Then with the Species Table you need to set the MasterSource and then click MasterFields. This will pop up a dialog then select the fields to connect in both columns then click Add.

That should do it.

[EDIT]
Er, I suppose you do have the exact same data in the appropriately linked Fields for both tables.
[/EDIT]

Garry

Edited by: Gary Cowlings on Jan 28, 2009 3:46 PM
0
Gary
1/28/2009 11:48:26 PM
Thanks Harry,

> I assume you have the correct Source assigned to the DBGrid2.
yes

> Also you need to have linked the 1-to-many in the Access Relationships.
did it when i created the access database

> Then with the Species Table you need to set the MasterSource and then 
> click MasterFields. This will pop up a dialog then select the fields to 
> connect in both columns then click Add.
>
> That should do it.


almost...

I got it working.  I removed the ADOConnection2 that was connected to 
species and replaced it with a TADOTable then set the master source and 
master fields.

I wonder if I should add a TADOTable to the LakeMaps? ... but it works 
without it.

All I need to do is to be able to filter a the lakemaps show all the lakes 
with the selected species... ie... Show all the lakes that contain brook 
trout.

I have not done a lot of database delphi apps as you probably can tell... 
mostly imaging applications is my expertise <grin>...

Thanks for your help!

Bill
0
Bill
1/29/2009 12:15:22 AM
There are two ways to link a Master and detail table.
In the first way you use the Masterfields and IndexFields properties of the detail table to link the two.  Delphi filters the detail table based on values from the Masterfields that is uses to match the field valuse in the IndexFields.  To use this kind of link you would use a Select from the detail table with no where clause or like ended up with use a TadoTable.
This method of master detail linking works but it can be a performance problem if the detail table is large.

The second way to do it is to use a parameter in the detail query

Select * from Species where
speciesID - :LakeId

In this type of link Delphi will pull the value from the master table where the field name matches the parameter.  The parameterized query will fire when ever the master record changes.

As to where to find information
Try a Delphi help search on these two topics

Establishing master/detail relationships using parameters
and
Creating master/detail relationships

> 
> I have an Access database with 2 tables:
> 
> LakeMaps Table 1
> LakeID: AutoNumber
> Name: Text
> County: Text
> Town: Text
>  Area: Number
>  MaximumDepth: Number
>  MeanDepth: Number
>  MapFilename: Number
> 
> Species Table 2
> Species: Text
> SpeciesID: Number
> 
> LakeID is linked to SpeciesID in a One-To-Many relationship
> 
> In Microsoft Access a form shows the lake information and species 
> information in each lake correctly.
> 
> 
> Delphi 2009
> 
> A Delphi 2009 application with a TADOConnection, 2 TDataSource with 2 
> TADODatasets and 2 DBGrids
> ADOConnection1 the TADOConnection.ConnectionString points to the mdb file.
> 
> LakeSource.DataSet is LakeMaps
> DBGrid1.DataSource is LakeSource
> SpeciesSource.Dataset is Species
> LakeMaps TADODataset has a CommandText of Shape {select * from Lakemaps}
> Species TAdoDataSet.CommandText is blank
> DBGrid2.DataSource is SpeciesSource
> 
> The lake database is displayed correctly in the DBGrid1
> The species for each lake is empty in  DBGrid2.
> 
> This is similar to the ADO Shapes Demo.
> 
> 1. What else to I have to add to the LakeMaps TADODataset.CommandText so 
> that the species in each lake appears in DBGrid2?
> 2. Where can I find information about TADODataset.CommandText?  A search of 
> the internet does not provide much info.
> 
> Regards,
> 
> Bill
0
Brian
1/29/2009 2:51:26 AM
> {quote:title=Bill Miller wrote:}{quote}

> I removed the ADOConnection2 that was connected to 

Hmmm, Bill, you never mentioned you had two ADOConnections.

If you have one mdb file then you only need one ADOConnection with DataSource+ADOTable for each table within the mdb

Maybe take a read here...
http://delphi.about.com/od/database/a/databasecourse.htm
0
Gary
1/29/2009 11:51:43 AM
Reply:

Similar Artilces:

How to access Delphi 7 & 2009 after purchasing Delphi XE
I have purchased and installed Delphi XE and now I'm unable to find information on how to download previous versions of Delphi, namely Delphi 7 and 2009. Please respond. Regards, SB, L&T Hi sushweta biswas, > I have purchased and installed Delphi XE and now I'm unable to find information on how to download previous versions of Delphi, namely Delphi 7 and 2009. Your reseller should have told you: after registering Delphi XE, you can go to http://www.embarcadero.com/xe-earlier-versions to enter your serial number of Delphi XE as well as your EDN account informati...

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

Delphi 4 to Delphi 2009
Hello, Thanks to all who answered my previous question. That was a great help. And atlast our client agreed to upgrade our delphi version from 4 to Delphi 2009. *Sigh*. But before that, I need to give the estimation and cost regarding the migration to delphi 2009. Can anyone tell me is there any tool to migrate from delphi 4 to delphi 2009 or just I need to compile our Delphi 4 application in Delphi 2009. I have read from the delphi 2009 feature matrix that Delphi 1 through Delphi 2007 import is possible in delphi 2009. But i am not that sure considering the size of our application. ...

Nice, Delphi XE includes free access to earlier version licenses and downloads for Delphi 2010, 2009, 2007 and 7.
Looking at the details for Delphi XE Professional while checking the prices etc and found the above as part of a paragraph. "Delphi XE includes free access to earlier version licenses and downloads for Delphi 2010, 2009, 2007 and 7. Details will be included with your order confirmation email and in the product readme." Very nice bonus! Brian > {quote:title=Brian Evans wrote:}{quote} > Looking at the details for Delphi XE Professional while checking the > prices etc and found the above as part of a paragraph. > > "Delphi XE includes free acce...

Convert Delphi 5 ADO App to Delphi 2007 ADO.NET
I have an appliction tha that is writen in Delphi 5 with ADOConnetion, ADOTable, and ADOQuery components. I need to upgrade to Delphi 2007 and use ADO.NET. I have the program building in with Delphi 2007. Is there anything I need to do to convert the ADO to ADO.NET? > I need to upgrade to Delphi 2007 and use ADO.NET. Why ? -- With best regards, Dmitry Arefiev AnyDAC (www.anydac.com) - Oracle, MS SQL Server, IBM DB2, MySQL, Firebird, Interbase, PostgreSQL, Sybase ASA, SQLite, MS Access, DBX, ODBC, InMem - universal high-speed native data access engine Reasons for ...

Upgrading to Delphi 2009 from Delphi 5
I've decided it's time to upgrade to Delphi 2009 Professional from my current Delphi 5 Professional which (according to the FAQ) makes me eligible for the upgrade pricing. However, I'd just like to clarify how this process works. My concern is that my Delphi 5 is not registered on the CodeGear site and this doesn't seem to be possible as far as I can tell. When installing the trial I noticed that Delphi 2009 registers itself with your CodeGear account so does this mean that the previous version must be registered there to verify you own a Professional edition? I plan to o...

I can to install one not delphi program foir iOS into one iOS for delphi?
For example i have one programm builded as xcode for iOS, and i build one program as delphi for iOS. I want to have only one instalation, i can to add this xcode program into my delphi installer of my ios program? I can to do the same as android? how i can to to this? > {quote:title=oscar mejia wrote:}{quote} > For example i have one programm builded as xcode for iOS, and i build one program as delphi for iOS. I want to have only one instalation, i can to add this xcode program into my delphi installer of my ios program? > > I can to do the same as android? how i can to to...

Delphi 7 to Delphi 2009 conversion
Hello group, What do I need to do to comile the following code in D2009. Compiler error after the Else E2010: Incompatible Types 'AnsiChar' and 'Char' if isUnicode then SearchHandle := FindFirstFilew( PWideChar( fn ), FindDataW ) else SearchHandle := FindFirstFile( PAnsiChar( Ansistring( fn ) ), FindDataA ); <<<<<compiler error in the above line >>>>>>>>>>> Regards, Bryan > What do I need to do to comile the following code in D2009. > Compiler error after the Else > E2010: Incompati...

is there a Delphi 2007
Would be nice to have a bundle of the latest Delphi packages. Gilbert Padilla wrote: > Would be nice to have a bundle of the latest Delphi packages. > I expect Delphi 2007 will only be on sale until the full RAD Studio 2009 edition is published, including Delphi 2009.net. W ...

Delphi 2009 alongside Delphi 2007
Hi all, I am about to install Delphi 2009 on the same development system as Delphi 2007, before I embark is there anything I should be aware of so as to not break my Delphi 2007 installation and projects ? Thanks JT John Taylor wrote: > Hi all, > > I am about to install Delphi 2009 on the same development system > as Delphi 2007, before I embark is there anything I should be aware > of so as to not break my Delphi 2007 installation and projects ? As long as you install into a separate folder there is no problem with the two versions getting into each other...

Delphi 2007 to Delphi 2009 Conversion
CharArrayPtr = ^CharArray; CharArray = array[0..MaxInt-1] of Char; How to convert to Delphi 2009? Bill Bill Miller wrote: > CharArrayPtr = ^CharArray; > CharArray = array[0..MaxInt-1] of Char; > > How to convert to Delphi 2009? > > Bill it depends heavelly on how it is used fearther down in your project and what you want to convert it to. I you want to simple convert the declarations ignoring UNicode altogether then the only think you have to change is the CharArray declaratin from a Char to an AnsiChar eg CharArrayPtr = ^CharArray; CharArray =...

How to: Window application with Delphi XE to access MS Access database?
I need to develop a Window application with Delphi XE to generate a form, which can display the data retrieved from an existing Microsoft Access database and update the data value in database as needed. Can someone advise me how should I get started and which implementation shall I use? Which tutorial materials can I look for? I am a new Delphi user. I called Embarcadero tech support on this subject, but got zero support from them. Thank you. Allen Allen, > I need to develop a Window application with Delphi XE to generate a form, > which can display the data retrieved fro...

Good (Free) Database Choice For Simple Local Database For Delphi 2009
For years I have used the BDE and dVolga ( no longer abailable ) but want to learn how to use other third-party and/or Delphi 2009 vcl components for simple databases. For a simple local database with only one table and 6-8 string fields with graphic field support for one field what is a good choice? What is available to do this without buying anything or possibly with a freeware component? Should I use DBExpress? Is a commercial database application necessary to create the database? Is something available from Microsoft as a free download to create and possibly edit a...

Why does this work fine in Delphi 2009, but not in Delphi 2010
I've been racking my head trying to figure this out and can't understand what is wrong, TFileStream.ReadComponentRes fails when I try to read a component containing a record, it works fine in Delphi 2009 and Delphi 2007, but fails with Delphi 2010 Here is the unit source and DFM *+//UnitSource+* unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TThresholdMode = (tm0,tm1,tm2,tm3,tm4,tm5); TThreshold = Record Mode:TThresholdMode; Filter,Start,Stop:Integer; end; ...

Web resources about - Microsoft Access, ADO and One-to-Many relationship Delphi 2009 - embarcadero.delphi.database

Same-sex relationship - Wikipedia, the free encyclopedia
A same-sex relationship is a relationship between two persons of the same sex and can take many forms, from romantic and sexual , to non-romantic ...

Entity-relationship model - Wikipedia, the free encyclopedia
In software engineering , an entity-relationship model ( ER model for short) is an abstract and conceptual representation of data . Entity-relationship ...

Ex-principal spared jail again over sexual relationship with teen
A former principal who had a sexual relationship with a 17-year-old girl student - conduct a magistrate labelled &quot;morally repugnant&quot; ...




Donald Trump says he has a 'very great' relationship with God, warns Christianity is 'under siege'
Donald Trump has warned that Christianity is &quot;under siege&quot; In a speech today to evangelical Christians at Liberty University in Virginia, ...

Hillary: My Relationship With Putin Is One Of Respect
'Well, my relationship with him, it's it's, it's interesting'

Relationships From All Perspectives: FXX’s ‘Man Seeking Woman’ Season 2 – TCA
“When it comes to dating,” said Simon Rich, creator/EP of FXX’s Man Seeking Woman at TCA today, “it doesn’t matter who you are: It’s a living ...

Nintendo expands upon same-sex relationships in Fire Emblem Fates
... (what arena of gaming doesn't have controversy surrounding it these days?), Nintendo has finally spoken up on the matter of same-sex relationships ...

Resources last updated: 1/23/2016 12:47:38 AM