Alvise Nicoletti wrote:
On windows with a graphical application lazarus created just the
commands you wrote there, on linux with a non-graphical application I'm
not compiling the same code.
With control+space on windows TMySQL50Connection is listed including
those units on the "uses" row, on linux I included the same units but
TMySQL50Connection is not recognized.
I found some corrispondences on the "sqldb" component, including that I
got both "TSQLConnection" and "TSQLQuery" but I suppose theyre different
things... (from the ones you showed me).
TSQLConnection is an abstract class; MySQL50Conn (or MySQL40Conn or
MySQL41Conn) provide classes like TMySQL50Connection that implement the
abstract methods of the former.
By contrast, TSQLQuery is not abstract, so you will use that class in your
program.
Below is a example program snippet (copy & pasted and stripped down version of
some test program of mine). I'm not 100% sure whether you need the TSQLTransaction,
but anyway this shows how it could be used.
Conn:=TMySQL50Connection.Create(nil);
Trans:=TSQLTransaction.Create(nil);
Qry:=TSQLQuery.Create(nil);
try
Conn.UserName:='****';
Conn.Password:='****';
Conn.DatabaseName:='*****';
Conn.Transaction:=Trans;
Conn.Open;
try
Qry.DataBase:=Conn; // very important
Qry.Transaction:=Trans;
Qry.SQL.Add('SELECT * FROM myTable');
// the following two statements are optional
Qry.ParseSQL:=false;
Qry.ReadOnly:=true;
Qry.Open;
try
Qry.First;
while not Qry.EOF do begin
//
// do something with the current record
//
Qry.Next
end;
finally
Qry.Close;
end;
finally
Conn.Close;
end;
finally
Qry.Free;
Trans.Free;
Conn.Free;
end;
Note that for non-INSERT queries, you can use Qry.ExecSQL; this will not open a
result set.
Regards,
Bram
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives