Does anyone know of a simple tuturial for setting up and using Delphi 2010 with MySQL?
A:
Use TAdoConnection and TAdoQuery:
implementation
uses adodb;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
mAdoConnection: TAdoConnection;
mAdoQuery: TAdoQuery;
begin
mAdoConnection := TAdoConnection.Create(application);
mAdoConnection.ConnectionString := 'Mode=ReadWrite;Extended Properties="DRIVER=MySQL ODBC 3.51 Driver;DATABASE=mydatabase;SERVER=myserver;UID=myusername;PASSWORD=mypassword;PORT=;OPTION=3;STMT=;"';
mAdoConnection.LoginPrompt := False;
mAdoConnection.Open;
mAdoQuery:=TADOQuery.Create(application);
with mAdoQuery do begin
Connection:=mADOConnection;
CursorType := ctStatic;
ParamCheck := False;
SQL.Add('SELECT * FROM SYSSET');
end;
mAdoQuery.Open;
showmessage(mAdoQuery.fields[0].AsString);
mAdoQuery.free;
mAdoConnection.Free;
end;
Note: change the "My....." to your server, database, username and password. This also assumes you have the MySql ODBC driver installed on the computer.
M Schenkel
2009-11-23 03:00:22
+1
A:
dbExpress is included in Delphi 2010 which supports mySQL
For a ODBC solution, this article should get you started: Using Delphi with MySQL"
Also, these resources should prove useful:
- ZeosLib
- Direct SQL (also see article MySQL and Delphi)
- mysql.pas
- TmySQL
- MyComponents
- MyDAC
Finally, have a look here: Delphi 2010 Compatible Third Party Tools & Components for some commercial packages.
Adrian
2009-11-23 22:36:23
I would vote for dbexpress. I will be more easy to switch to another database.
Hugues Van Landeghem
2009-11-27 22:17:33
My vote to AnyDAC.
oodesigner
2010-09-23 05:18:05
A:
lallous
2009-11-25 11:48:32