Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Learning ADO & Delphi. Frowned Upon?

Status
Not open for further replies.

cascot

Programmer
Jan 30, 2002
127
CA
I recently began using Delphi again for a new project (I'm still a novice). My project involves writing to a local database, and it seems the best approach to that is to use the ADO components. Having said that, it is proving almost impossible to find a comprehensive reference to using these components (ADOTable, ADODataset, ADOQuery, etc). While it is a breeze to find code examples for (say) VB & ADO, showing the most efficient methods for adding single records, adding batches of records, editing a single record, deleting multiple records, etc, etc. There seems to be no such examples for Delphi & ADO, just a very sparse sprinkling of newsgroup postings, many of which disagree with each other on the most efficient approaches to these common tasks. The Borland guides and help are essentially the same (no comprehensive example code). Why is this? Is it because Borland would rather developers steer clear of ADO? And what can I do? Should I abandon Delphi or maybe make use of other Delphi database components? Any thoughts, URLs, etc would be much appreciated.
 

Using Delphi 7 and ADO here. Far better than BDE. The minimum you need are TADOConnection and TADOQuery.

TADOConnection will build the connection string for you. Then set the connection property of a TADOQuery to the TADOConnection.

For reading data, set the SQL.Text property to your SQL statement and then use Open, loop on Next while not Eof (access the Fields collection to see your data), and Close.

For updating/inserting data, set the SQL.Text property to your SQL statement and use the ExecSQL method.

Once you have the basics down, then you can explore other features like parameters, stored procedures and data aware components.

 
Thanks for your reply Zathras. I have been able to create a connection and add a record to the parent table, as well as get the ID of the record added. I was also then able to add all the child records, however the update was way slower than I would have hoped for. The reason is because I am not applying the new records in a batch. I'm sure I am also doing things in terms of activating, closing the components, etc that is less than perfect. That is why I am seeking example code, preferably from official Delphi sources, though I'll settle for almost anything at this stage. The Delphi help is plentiful in words, but short on actual component specific example code.
 
Hi,

there are some good books out there which cover your topic, here's one :


there are also many online sources, the delphi.about.com is one of my favorites :


offcourse google will reveal a lot more links.
if you have specific problems with your code, then this is the right place to ask your question (which you did :) )

happy posting,
Daddy.


--------------------------------------
What You See Is What You Get
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top