Retrieving data from database

Retrieving data from database

Postby RiF » Wed 16 Mar 2005 04:22

Hi All!

Sorry for the so simply question, but: how to retrieve data from my database with MyDAC ?

Please write some code ;)

Sorry for bad English.
RiF
 

Postby Ikar » Wed 16 Mar 2005 07:41

Please see MyDAC/Demos folder
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Re: Retrieving data from database

Postby roman » Thu 17 Mar 2005 20:42

RiF wrote:how to retrieve data from my database with MyDAC ?


In pretty much the same way as with any other sql-based dataset- you setup a connection and link a MyQuery component to it.

To setup a connection you use a TMyConnection component. The relevant properties are:

  • Server - the address where the MySql server resides
  • User - the MySql user to connect to the server
  • Password - the user's password
  • Database - the default database used in the connection


To link a TMyQuery component to a TMyConnection component use its Connection property, although this is rarely necessary: When you drop a TMyQuery component into a form or data module, MyDAC automatically searches for available connections. If there is one, it connects the dropped MyQuery to it. If there is more than one, it asks you which one to use.

From this point on, you work as usual: specify the SQL statement in the MyQuery's SQL property, send out the query with its Open method, traverse the returned rows with its Next method using FieldByName to retrieve field values or bind MyQuery directly to whichever data aware controls you wish through a DataSource.
roman
 
Posts: 5
Joined: Thu 24 Feb 2005 05:44


Return to MySQL Data Access Components