[lazarus] Still :I need help with databases.
HSO
hso.suporte at ig.com.br
Wed Feb 19 22:39:00 EST 2003
Hi all.
I`m still having troubles with databases, i sow the database objects you have send before in the list, but i don`t know how to compile then(well therefore i asked for components like delphi , actualy i don`t like then i prefer doing things like i do in c++ wich means using the mysql unit from freepascal).
So i wrote a small pascal prg accessing a mysql database , it worked fine,so i copied it into a lazarus unit(the callback off a button) i tryed to run this.The program display the correct result and then stop misteriusly.
gdb does not work, so i got completely lost, can you help me?
I`m sending the two codes(the unit from lazarus and the pas prg).
unit uni1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, LResources, Buttons,mysql;
type
TForm1 = class(TForm)
Button1: TBUTTON;
procedure Button1CLICK(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
db:PMYSQL;
tmp:TMYSQL;
coluna:TMYSQL_ROW;
buffer:PMYSQL_RES;
implementation
{ TForm1 }
procedure TForm1.Button1CLICK(Sender: TObject);
begin
db:=mysql_connect(@tmp,'localhost','root',nil);
mysql_select_db(db,'delara');
mysql_query(db,'select * from usuarios');
buffer := mysql_store_result(db);
coluna:=mysql_fetch_row(buffer);
showmessage(coluna[0]);
mysql_close(db);
end;
initialization
{$I uni1.lrs}
end.
program teste;
uses mysql;
var
db:PMYSQL;
tmp:TMYSQL;
coluna:TMYSQL_ROW;
buffer:PMYSQL_RES;
begin
db:=mysql_connect(@tmp,'localhost','root',nil);
mysql_select_db(db,'delara');
mysql_query(db,'select * from usuarios');
buffer := mysql_store_result(db);
coluna:=mysql_fetch_row(buffer);
writeln(coluna[0],coluna[1]);
end.
More information about the Lazarus
mailing list