unit fMain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uMyDll, StdCtrls, WideStrings, DBXMySql, DB, SqlExpr, Grids; type TForm1 = class(TForm) Button1: TButton; StringGrid1: TStringGrid; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} uses Math; procedure TForm1.Button1Click(Sender: TObject); var aVar: TMyVar; aField: TMyField; iConn: Longint; i, c: LongInt; j: Longint; begin // the dll handles the char* memory allocations, so set to nil before we start aField.sName := nil; aVar.sValue := nil; // create a new internal class object iConn := mydll_createNewConnection; // set connection options mydll_setOptions( iConn, 'db.my.ip.or.host.name', 3306, 'myusername', 'mypassword' ); // mysql_real_connect() if mydll_connect( iConn ) then begin // mysql_select_db() if mydll_selectDatabase( iConn, 'DKP' ) then begin // mysql_query() if mydll_openQuery( iConn, 'select * from dkp_char' ) then begin // mysql_get_num_cols() c := mydll_getFieldCount( iConn ) - 1; // mysql_get_num_rows() StringGrid1.RowCount := Math.Max( 2, mydll_getRecordCount( iConn ) ); StringGrid1.FixedCols := 0; StringGrid1.ColCount := c + 1; for i := 0 to c do begin // puts field data into aField mydll_fetchField( iConn, i, @aField ); StringGrid1.Cols[i][0] := aField.sName; end; j := 1; // mysql_fetch_row() while mydll_next(iConn) do begin for i := 0 to c do begin // we pretend it's a string (iDatatype=0) because it's too much trouble to bother with storing the fields+datatypes in a dynamic array // puts value of field [i] data into aVar mydll_fetchValue( iConn, i, 0, @aVar ); StringGrid1.Cells[i,j] := aVar.sValue; end; Inc( j ); end; end; end; // mysql_close() mydll_disconnect( iConn ); end; // delete internal class object mydll_closeConnection( iConn ); // ps. Yes, 2 char* memory allocations are leaking at this point, should be a function for that to handle the leaking fields and values end; end.