Connect to mysql from a console app hangs in IDE but not out of it lazarus / 16-Databases ---------------------------------------------------------------------- kokorini · 2010-02-15 20:25 Hello. First: thanks for reading. now, I'm trying to connect to mysql from a console application. Using an application where you drag an drop controls to the form it connects OK but I don't know why I can't make it work on a console app. here is my code, it loads from an external .txt the configuration, that works fine: Code: [Select]       MySQL := TMySQL50Connection.Create(nil);       MyTransaction := TSQLTransaction.Create(nil) ;       MyQuery := TSQLQuery.Create(nil);       MyTransaction.Database := MySQL ;       MyQuery.DataBase := MySQL ;       MyQuery.Transaction := MyTransaction ;       MySQL.Transaction := MyTransaction ;        AssignFile(F, config_file_name) ;        reset(F) ;        readln(F,mysql_host) ;        readln(F,mysql_user) ;        readln(F,mysql_pass) ;        readln(F,mysql_dbname) ;        closefile(F) ;        MySQL.HostName := mysql_host ;        MySQL.UserName := mysql_user ;        MySQL.Password := mysql_pass ;        MySQL.databasename := mysql_dbname ;        MySQL.Connected := True ; And... when the last line is excecuted the program stop responding, no errors, no exceptions... just nothing. OH! just after I post,  I have an idea: run the program without the IDE... IT WoRKS!!! so, the problem is that when I'm in the IDE, the program stop responding when I try to connect. But I runs ok if I run it from a console, without the IDE. lazarus bug?? hope not this is a TCustomApplication, with lazarus 9.28.2-0 thank you FGrant ---------------------------------------------------------------------- fredycc · 2010-02-15 22:32 Hi kokorini I works with firebird & Zeos but is similar for establish connection, I use similar code for threading app with firebird, maybe the problems is your query because you have nothing; test it:       MySQL := TMySQL50Connection.Create(nil);            AssignFile(F, config_file_name) ;       reset(F) ;       readln(F,mysql_host) ;       readln(F,mysql_user) ;       readln(F,mysql_pass) ;       readln(F,mysql_dbname) ;       closefile(F) ;       MySQL.HostName := mysql_host ;       MySQL.UserName := mysql_user ;       MySQL.Password := mysql_pass ;       MySQL.databasename := mysql_dbname ;       Try    MySQL.Connected := True;       except    on E: Exception do     Showmessage(E.message)       end; ---------------------------------------------------------------------- kokorini · 2010-02-16 15:43 Hi... thank you for your help. but it didn't solve the problem, when connect := true  the programs hangs in the IDE and not out of it. trying "things" I reduce the program to minimal like this: Code: [Select]program Project1; {$mode objfpc}{$H+} uses   {$IFDEF UNIX}{$IFDEF UseCThreads}   cthreads,   {$ENDIF}{$ENDIF}   Classes, mysql50conn, sqldb   { you can add units after this }; {$IFDEF WINDOWS}{$R project1.rc}{$ENDIF} var  conn : TMySQL50Connection ;  s : string ; begin   conn := TMySQL50Connection.Create(nil);   conn.Connected := True;  //THE PROGRAM HANGS HERE   s := 'nothing' ; end. I know I haven't set the host, username, nothing... but setting those things before connect give the same result. Let me be more clear... if I put a breakpoint on the line when the comment "//the program...." the program never pass that line. But if I excecute the program from the console, it works fine (setting the hostname, username, etc... of course). I tried to see what happend without settings hostname, username, etc to see if it was a version problem with the mysql server, but becouse it hangs in the same way, I think the problem is on the IDE, or it seems to be. I'm using a very fresh ubuntu 8.04 32bits installation, with a fresh lazarus. thank you again FGrant