Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - Using Delphi with ADO
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Using Delphi with ADO
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2006-10-02

    Table of Contents:
  • Using Delphi with ADO
  • Accessing Database Content
  • Practical Example with Data Aware Components
  • Practical Example Without Data Aware Components

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Using Delphi with ADO - Practical Example with Data Aware Components


    (Page 3 of 4 )

    Drop an ADOTdotable component from the ADO tab (rename to ado1), then go to the Data Access tab and drop a datasource component. Once you've done that, go to the Data Controls tab and drop DBGrid and DBNavigator (rename to dbnav) components.

    Now make the following connections:

    Select the datasource component, go to the object inspectors properties tab, then go to the Data Set property on the drop-down list. You should see ado1; select it.

    Select the ado1 component and go to its connection string property. Click on the ellipses button and a screen should come up that looks like this:

    Click on build. A screen that looks like this should pop up:

    Select Jet 4 OLE DB and click next. A screen that looks like this should pop up:

    Click on the ellipses button on option number 1. Go to where you've stored the database that you've downloaded from this article. Click OK, then OK again.

    Now, click on the DBGrid component and select its data source property. In the drop down list, you should see  datasource1 as an item on that list. Select it.

    Finally, select the dbnav component and on its datasource property, select datasource1.

    At this point your form should look something like this:

    Now we are done with the component connection. We now need to select a  table from the database that we want to work with. Our database has only one table called person, so go to the TableName property of the ADOTable component and select "person." 

    You can view the contents of the database in design time simply by setting the active property of the ADOTable to true. The same thing is done at run time to view the contents:

    Have a look at the table contents at design time:

    As you can see, it is very easy to view the contents of a table when using ADO with Data Aware components, both at design time and run time, all without writing a single line of code! To change the data in the table, simply double click on the line that you want to change and change the data.

    To actually work with the data, as in changing, adding and deleting records, we are going to use the database navigation component. This component makes it easy for us to add, remove and change database content:

    In ADO, when you (for example) want to change a record, the table is set in edit mode, and after you've made your changes, you need to post those changes to the database. Posting changes is the same as saving the changes you make in a document. In fact you need to post any changes that you make to the database, so that the database can refresh and reflect the changes you made.

    More Delphi-Kylix Articles
    More By Jacques Noah


       · the database "people.mdb" is missing from the download. Any chance of having the...
       · OK the MDB file is in the zip now but.... there are no tables in the database???
       · I'll have a look at the file and upload a proper one. Thanks.
       · it seems that mister Jacques Noah forgot about the common people in his quest for...
     

    DELPHI-KYLIX ARTICLES

    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...
    - Using Try and Finally to Help Prevent Memory...
    - The Implementation of an FTP Server
    - FTP Server: The Theory







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway