Would like an example of accessing a MySQL DB in Delphi 7.

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
Chesso
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 07.12.2005, 03:45
Location: Sydney - Australia

Would like an example of accessing a MySQL DB in Delphi 7.

Post by Chesso »

Hello im new here(and new to anything db related besides some simple php/mysql) :).

Im wondering if anyone can show me an example(and explain) how i can access(read/write) to a MySQL Database. Im pretty sure the version is 4.1 it's with EasyPHP along with apache.

The database i need to access is a friends because im making a front-end gui for his console application and being able to access(read/write) accounts would be very usefull.

Thanks in advance.
zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Post by zippo »

Excuse me, but I'm not sure and I have to ask: You want to di it in Delphi, right?

Well if this is correct, then you can do the following:

Set the query property to RequestLive := true (this enables writing)

To open a query, just fill the SQL property (example MyQry.SQL.Text := 'Select * From TABLE') and execute the .Open method.

Now to edit you can do this (I presume you are located on the row you want to edit, if not use Next, Previous or Locate methods of MyQry).

MyQry.Edit
MyQRY.FieldByName('MY_FIELD').AsString := 'hello'. You can use AsInteger, AsFloat, AsDateTime,... etc. Consult the help.

MyQry.Post.

This is manually, but if you use the DB components (TDBEdit, TDBGrid,.. etc.) the most is done automatically.

It seems complex here, but it's easy when you have enough drill :)
Chesso
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 07.12.2005, 03:45
Location: Sydney - Australia

Post by Chesso »

Heh heh yeah delphi, im just interested to know how exactly does it know that MySQL is running and such it's a question that's been bugging me :P
Chesso
Fresh Boarder
Fresh Boarder
Posts: 3
Joined: 07.12.2005, 03:45
Location: Sydney - Australia

Post by Chesso »

Sorry for the double post but i just came across something, i opened one of the example projects in Delphi 7 and it refused to compile(saying RequestLive property or something didn't exist among other errors).

Im using 6.5.1 alpha CVS is their perhaps an older version i should use? i need to access MySQL 4.1.
Michael
ZeosLib's Handyman :o)
ZeosLib's Handyman :o)
Posts: 189
Joined: 15.08.2005, 16:08
Location: Wehrheim
Contact:

Post by Michael »

Hi Chesso,

the examples are not fully adapted to the 6.5.1 alpha, yet. But one thing I can tell you so far: RequestLive changed to ReadOnly. Where RequestLive = true means ReadOnly = false (the default setting!).

Please read the "changes.htm" that comes with the each CVS-build and you will be informed.

Regards.

P.S.: To get into ZeosLib's DBOs I would suggest to read this article of our Knowledge base: The ZeosLib DBOs 6.1.5 with Delphi 7 and Firebird 1.5. Even if it's Firebird we are talking about the basics are the same... ;-)
:prog2: Use the source, dude!

[align=right]..::.. ZeosLib on SourceForge ..::..[/align]
Post Reply