Page 1 of 1

Can not connect to mysql [solved]

Posted: 28.01.2010, 21:43
by deadflowers
hi all, iam new bie to use zeos and i have probelm when i am try to connect mysql. my error message database connection component is not assigned. i use delphi 7 and mysql server 5.0.16-nt.

and this my code :

Code: Select all

var 
   Db:TZConnection;
   query:TZQuery;
begin
Db:=TZConnection.Create(nil);
    Db.Protocol:='mysql';
    Db.HostName:='localhost';
    Db.Database:='bali';
    Db.User:='root';
    Db.Password:='';
    query:=TZQuery.Create(nil);
    query.SQL.Clear;
    query.SQL.Add('SELECT * from inbox limit 0,10');
    query.Open;
    query.Last;
    writeln(query.FieldByName('Text').AsString);
    query.Close;
    Db.Free;
end;

Posted: 28.01.2010, 22:01
by jeckson
try it

Code: Select all

var
Db:TZConnection;
query:TZQuery;
begin
Db:=TZConnection.Create(nil);
Db.Protocol:='mysql';
Db.HostName:='localhost';
Db.Database:='bali';
Db.User:='root';
Db.Password:='';
query:=TZQuery.Create(nil);
query.Connection := DB;
query.SQL.Clear;
query.SQL.Add('SELECT * from inbox limit 0,10');
query.Open;
query.Last;
writeln(query.FieldByName('Text').AsString);
query.Close;
Db.Free;
end;

Posted: 28.01.2010, 22:05
by deadflowers
wow..its work..iam try to add query.Connection := DB;

thxs....