7
DataBase : Pchar = 'testdb';
8
Query : Pchar = 'Select * from FPdev';
23
Dummy:=Paramstr(1)+#0;
26
Write ('Connecting to MySQL...');
27
mysql_init(PMySQL(@qmysql));
28
sock := mysql_real_connect(PMysql(@qmysql),nil,'michael','geen',nil,0,nil,0);
31
Writeln (stderr,'Couldn''t connect to MySQL.');
32
Writeln (stderr,mysql_error(@qmysql));
36
Writeln ('Connection data:');
38
writeln ('Mysql_port : ',mysql_port);
39
writeln ('Mysql_unix_port : ',mysql_unix_port);
41
writeln ('Host info : ',mysql_get_host_info(sock));
42
writeln ('Server info : ',mysql_stat(sock));
43
writeln ('Client info : ',mysql_get_client_info);
45
Writeln ('Selecting Database ',DataBase,'...');
46
if mysql_select_db(sock,DataBase) < 0 then
48
Writeln (stderr,'Couldn''t select database ',Database);
49
Writeln (stderr,mysql_error(sock));
53
writeln ('Executing query : ',Query,'...');
54
if (mysql_query(sock,Query) < 0) then
56
Writeln (stderr,'Query failed ');
57
writeln (stderr,mysql_error(sock));
61
recbuf := mysql_store_result(sock);
64
Writeln ('Query returned nil result.');
68
Writeln ('Number of records returned : ',mysql_num_rows (recbuf));
69
Writeln ('Number of fields per record : ',mysql_num_fields(recbuf));
71
rowbuf := mysql_fetch_row(recbuf);
72
while (rowbuf <>nil) do
74
Write ('(Id: ', rowbuf[0]);
75
Write (', Name: ', rowbuf[1]);
76
Writeln(', Email : ', rowbuf[2],')');
77
rowbuf := mysql_fetch_row(recbuf);
79
Writeln ('Freeing memory occupied by result set...');
80
mysql_free_result (recbuf);
82
Writeln ('Closing connection with MySQL.');