Hi,
I try to connect to a MySQL-Server that runs on localhost:3306.
With java and MySQL-connector this works fine.
Now I want to do that with fpc.
I used the tutorial on the wiki
http://wiki.lazarus.freepascal.org/index.php/Lazarus_Database_Tutorial#Lazarus_and_MySQLThis is my function:
//uses MySQL3 just for info
function fConnect(const Host, User, Passwd: PChar) : boolean;
var mysql : TMYSQL;
alloc, sock : PMYSQL;
res : boolean;
begin
res := true;
alloc := mysql_init(@mysql);
write('Connecting to MySQL... ');
//sock := mysql_connect(alloc, host, user, Passwd);
sock := mysql_real_connect(alloc, host, user, Passwd, 0, nil, 0);
if assigned(sock) THEN
begin
Writeln('done');
Writeln('Connection data:');
Writeln ('Host info : ',mysql_get_host_info(sock));
Writeln ('Server info : ',mysql_stat(sock));
Writeln ('Client info : ',mysql_get_client_info);
end
else
begin
res := false;
writeln('failed');
writeln(stderr, mysql_error(@mysql));
end;
fConnect := res;
end;
But I get following error message:
Can't create TCP/IP socket (10106)
Version of MySQL 3.23 (but I'm currently downloading 4.1)
So what am I doing wrong, or is it a bug?
Regards
Fabian