Newbie easy question..

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
dzairo
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 31.03.2011, 18:30
Location: Kosice

Newbie easy question..

Post by dzairo »

Hi.
I have Delphi 7 and install Zeos Lib 6.6.6-stable.
I'm newbie and want start with MySQL on Delphi.
I have easy question for step by step ....
On new project I put to new form ZConnection and define user password and HostName.

question :
I how can I check if exists any database or no???
.. how can I check if exists any table on defined database???
.. how can I check how many record are in table ???


this easy question is my first .
Pls answer someone.
regards
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Connect after adding 'dbless=true' to ZConnection.Properties.
Then you have the following ZConnection methods to retrieve this information:

procedure GetCatalogNames(List: TStrings);
procedure GetSchemaNames(List: TStrings);
procedure GetTableNames(const Pattern: string; List: TStrings);overload;
procedure GetTableNames(const tablePattern,schemaPattern: string; List: TStrings);overload;
procedure GetTableNames(const tablePattern,schemaPattern: string; Types: TStringDynArray; List: TStrings);overload;
procedure GetColumnNames(const TablePattern, ColumnPattern: string; List: TStrings);
Image
dzairo
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 31.03.2011, 18:30
Location: Kosice

Post by dzairo »

Hi.
If I'm good understand then:
GetCatalogNames - list all databases in MySQL server , on this list can find my database
GetTableNames - list all tables in defined database

but what do you mean with this:
'dbless=true' to ZConnection.Properties

I'm beginner for MySQL database in Delphi.
I thinks so will good make more small example with easy function for all beginner like my.

and if I want list all data from defined field ????
how can do this ???
dzairo
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: 31.03.2011, 18:30
Location: Kosice

Post by dzairo »

Hi.
For read all data from defined field to comboBox I use this :

Code: Select all

i:=1;
  while i <= ZQuery1.RecordCount do
  begin
  ComboBox1.Items.Append(ZQuery1.fieldByName('gvyrobca').AsString);
  ZQuery1.Next;
  i:=i+1;
  end;
  Combobox1.ItemIndex:=0;
I can use this or exist other way???
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

ZConnection.Properties is a TStringList. Add a line to this list which contains 'dbless=true' This way the library knows it should connect to the database server without setting a database active.
Attention : you can use this for loading a list with available databases, but you should close this connection afterwards so you can reconnect with the chosen database. (don't forget to remove the 'dbless=true' from your connection properties)

Seeing your second question I think : 'Please, read some from the Delphi TDataset Help'. A TZQuery is a TDataset descendant, so in most cases it's behaviour is equal (or at least very similar).
For the answer of this question, have a look at TDataset.EOF documentation. For Delphi 7 the example is clear. I suppose it's clear for other Delphi versions too.
So here I refuse a more detailed example as you need to read more about working with Datasets before going on.
If you really can't work this one out after reading, please let me know.

Mark
Image
Post Reply