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.
Would like an example of accessing a MySQL DB in Delphi 7.
Moderators: gto, cipto_kh, EgonHugeist
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
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
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.
Im using 6.5.1 alpha CVS is their perhaps an older version i should use? i need to access MySQL 4.1.
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...
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...