Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2002-07

MySQL under Windows

13 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Fernando Lozano

Hi there,

I am using FPC 1.0.6 under Windows 98 and MySQL 3.23.49.

The simple test program bellow generates a run-time error 103 on the first write/writeln call unless I define the variable filler. Looks like binary incompatibilities between the pre-compiled Units and the MySQL DLL. Maybe you should distribute the libmysql.dll used when compiling FPC alongside the binaries. :-)

But when I tried to build a test program using FCL, I get an Internal Error when I try to open the Dataset. This other test program is also included so you can check what I've done wrong or help me find a workaround like the filler variable on the first test.

Please let me also ask what's the proper way to check for error (can't connect, wrong password, SQL syntax, no rights, ...) when using the FCL database classes.

[]s, Fernando Lozano

// first test program
program testemysql;
uses mysql;
const
    host = 'linuxfs';
    banco = 'poo';
    login = 'teste';
    senha = 'senha';
var
    bd : PMYSQL;
    qmysql : TMYSQL;
    filler : string;
    sql : ansistring;
    res : PMYSQL_RES;
    row : TMYSQL_ROW;
procedure erro (bd : PMYSQL; msg : string);
begin
    writeln (stderr, msg);
    writeln (stderr, mysql_error(bd));
    readln;
    halt(1);
end;
begin
    filler := '';
    bd :=  mysql_connect (PMysql (@qmysql), host, login, senha);
    if bd = Nil then
	erro (PMysql (@qmysql), 'Can't conect to MySQL server');
    if mysql_select_db (bd, banco) < 0 then
	erro (bd, 'Can't select the database ' + banco);
    sql := 'SELECT name, e_mail FROM addressbook';
    if mysql_query (bd, PChar (sql)) < 0 then
	erro (bd, 'Error on SELECT');
    res := mysql_store_result (bd);
    if (res = nil) then
	writeln ('There are no records')
    else begin
	row := mysql_fetch_row (res);
	while (row  nil) do begin
	    write ('name: ', row[0], ', ');
	    write ('e-mail: ', row[1]);
	    writeln;
	    row := mysql_fetch_row (res);
	end;
	mysql_free_result (res);
    end;
    mysql_close (bd);
    readln;
end.
// second test
program testedbmysql;
uses db, mysqldb;
const
    host = 'linuxfs';
    banco = 'poo';
    login = 'teste';
    senha = 'senha';
var
    bd : TMysqlDataset;
    filler : string;
procedure erro (bd : TMysqlDataset; msg : string);
begin
    //writeln (stderr, msg);
    //writeln (stderr, mysql_error(bd));
    writeln (msg);
    //writeln (mysql_error(bd));
    readln;
    halt(1);
end;
begin
    //filler := '';
    bd := TMysqlDataset.Create (nil);
    bd.Host := host;
    bd.Database := banco;
    bd.User := login;
    bd.Password := senha;
    bd.SQL.text := 'SELECT numero, saldo FROM conta_corrente';
    bd.Open;
    while not bd.EOF do begin
	write ('numero: ', bd.Fields[0].AsString, ', ');
	write ('saldo: ', bd.Fields[1].AsString);
	writeln;
	bd.Next;
    end;
    bd.Close;
    bd.Free;
    readln;
end.

Reply by email

Florian Klaempfl
to Fernando Lozano
you wrote 7 lines
Hi there, I am using FPC 1.0.6 under Windows 98 and MySQL 3.23.49. The simple test program bellow generates a run-time error 103 on the first write/writeln call unless I define the variable filler. Looks like binary incompatibilities between the pre-compiled Units and the MySQL DLL.

I just checked with 3.23.51 and the TMySQL record has indeed new fields. Any opionions about updating
the mysql import unit to match the 3.23.51 C headers?

Maybe you should distribute the libmysql.dll used when compiling FPC alongside the binaries. :-)

Hmmm, doesn't the libmysql.dll have to match the server?

Reply by email

Vassilis Stathopoulos
to Florian Klaempfl

Hello,

I am trying to use the Base64 Encoding and Decoding unit. I have an ansistring and I want to encode it and store it in another string.

I can't seem to make it work. I have tried multiple things - obviously I am missing something really simple (as always).

Anyone kind enough to share a demo of how this thing works? All I want is to encode a string and store it in another string...

Thank you in advance,

Vassilis

Reply by email

Sebastian Günther
to Vassilis Stathopoulos
Show quoted text 10 lines
Hello, I am trying to use the Base64 Encoding and Decoding unit. I have an ansistring and I want to encode it and store it in another string. I can't seem to make it work. I have tried multiple things - obviously I am missing something really simple (as always). Anyone kind enough to share a demo of how this thing works? All I want is to encode a string and store it in another string...

just have a look at the examples in the fcl/tests directory (b64dec.pp, b64enc.pp, b64test.pp, b64test2.pp)

- Sebastian

Reply by email

Vassilis Stathopoulos
to Sebastian Günther

I did so - that's why I sent this request :-)

Since this must be easy, can you help me and give me a different approach to these demos?

I can't seem to make it work (and I tried different approaches). I wouldn't send mail to the list if I haven't tried everything before...

Vassilis

Earlier message 32 lines
----- Original Message ----- From: "Sebastian Günther" To: Sent: Wednesday, July 24, 2002 8:12 PM Subject: Re: [fpc-pascal]Base64? > Vassilis Stathopoulos schrieb: > > Hello, > > > > I am trying to use the Base64 Encoding and Decoding unit. I have an > > ansistring and I want to encode it and store it in another string. > > > > I can't seem to make it work. I have tried multiple things - obviously I am > > missing something really simple (as always). > > > > Anyone kind enough to share a demo of how this thing works? All I want is to > > encode a string and store it in another string... > > > just have a look at the examples in the fcl/tests directory (b64dec.pp, > b64enc.pp, b64test.pp, b64test2.pp) > > > - Sebastian > > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Fernando Lozano

Hi Florian,

Show quoted text 7 lines
>I am using FPC 1.0.6 under Windows 98 and MySQL 3.23.49. > >The simple test program bellow generates a run-time error 103 I just checked with 3.23.51 and the TMySQL record has indeed new fields. Any opionions about updating the mysql import unit to match the 3.23.51 C headers?

I guess the record had changed before 3.23.51. Using the latest release availabe (and state this on the README so at least I know which release of MySQL to install) is the best for me.

>Maybe you should distribute the libmysql.dll used when compiling FPC >alongside the binaries. :-) Hmmm, doesn't the libmysql.dll have to match the server?

I guess no. The Windows port of PHP has allways included the mysql client DLLs and I never had problems whatever the MySQL version I used. Besides, I do not need to have a MySQL server on my Windows box, I may use a remote MySQL server on Linux.

If this were true, we'd have to allways recompile the MySQL unit to match our MySQL install. It doesn't makes sense.

[]s, Fernando Lozano

Reply by email

Mirek Novak
to Fernando Lozano: I am using FPC 1.0.6 under Windows 98 and MySQL 3.23.49. The simple test program bellow…

Hi,
at first I've to say, I've left FPC last year and switched to PHP :-). I'm monitoring this list to see changes an for (possible) future return. As for MySQL units for FPC this is is long-lasting problem and solution may be found in archive of this list. I've (2 years ago) got the same problem as U. It was caused by 2 things
1. library was written for client 3.21.* (this may changed)
2. library was written for linux only even it has some IFDEFs for windows, there was one fundamental "error" on windows there must be used stdcall instead of cdecl ... (so this may also be fixed)

I've all of this reported to mysql.pp mainteiner but, AFAIK, nothing has changed. I don't know what is current state and what is changed, bu what u've described is too similar to my problems. As I wrote, solution may be found in archive, some users have translated recent C headers and may send translated files to you, so search ... Another possible solution is to use older client lib (libmysql.dll). It AFAIK doesnt matter which version of client u're using to connect to server. It has to be backward compatible at level find out compatible lib to you translated mysql.pp file my tip is st. like 3.22.*

Fernando Lozano wrote 11 lines
Hi there, I am using FPC 1.0.6 under Windows 98 and MySQL 3.23.49. The simple test program bellow generates a run-time error 103 on the first write/writeln call unless I define the variable filler. Looks like binary incompatibilities between the pre-compiled Units and the MySQL DLL. Maybe you should distribute the libmysql.dll used when compiling FPC alongside the binaries. :-) But when I tried to build a test program using FCL, I get an Internal Error when I try to open the Dataset. This other test program is also included so you can check what I've done wrong or help me find a workaround like the filler variable on the first test. Please let me also ask what's the proper way to check for error (can't connect, wrong password, SQL syntax, no rights, ...) when using the FCL database classes. []s, Fernando Lozano

[...]

HTH,

-- Mirek Novak Anima Publishers CMS development http://www.auto.cz http://www.formule1.cz ISEEKYOU:1<one>9<four>9<nine>44<eight> GEsEm:+420603807838

Reply by email

Mirek Novak
to Fernando Lozano: I guess the record had changed before 3.23.51. Using the latest release availabe (and…
Fernando Lozano wrote 17 lines
Hi Florian, >>I am using FPC 1.0.6 under Windows 98 and MySQL 3.23.49. >> >>The simple test program bellow generates a run-time error 103 > >I just checked with 3.23.51 and the TMySQL record has indeed new fields. >Any opionions about updating >the mysql import unit to match the 3.23.51 C headers? I guess the record had changed before 3.23.51. Using the latest release availabe (and state this on the README so at least I know which release of MySQL to install) is the best for me. >>Maybe you should distribute the libmysql.dll used when compiling FPC >>alongside the binaries. :-)

YES - AFAIK its true.

> >Hmmm, doesn't the libmysql.dll have to match the server?

NO - client version is not dependent on server version as far as the communication protocol is not changed

Show quoted text 5 lines
I guess no. The Windows port of PHP has allways included the mysql client DLLs and I never had problems whatever the MySQL version I used. Besides, I do not need to have a MySQL server on my Windows box, I may use a remote MySQL server on Linux. If this were true, we'd have to allways recompile the MySQL unit to match our MySQL install. It doesn't makes sense.

(if client lib changes)

[]s, Fernando Lozano
-- Mirek Novak Anima Publishers CMS development http://www.auto.cz http://www.formule1.cz ISEEKYOU:1<one>9<four>9<nine>44<eight> GEsEm:+420603807838

Reply by email

Fernando Lozano

Hi Mirek,

As for MySQL units for FPC this is is long-lasting problem and solution may be found in archive of this list. I've (2 years ago) got the same problem as U. It was caused by 2 things 1. library was written for client 3.21.* (this may changed)

It looks like now it was built for 3.23.*. At least the libmysql.dll from 3.23.32 worked fine for me. :-)

But the FCL database classes still give me "Internal error". Can someone tell me if they are ready for use or if the test program I sent to the list contains some mistake?

[]s, Fernando Lozano

Reply by email

Mirek Novak
to Fernando Lozano
Fernando Lozano wrote 22 lines
Hi Mirek, >As for MySQL units for FPC this is is long-lasting problem and >solution may be found in archive of this >list. I've (2 years ago) got the same problem as U. It was caused by 2 things > 1. library was written for client 3.21.* (this may changed) It looks like now it was built for 3.23.*. At least the libmysql.dll from 3.23.32 worked fine for me. :-) But the FCL database classes still give me "Internal error". Can someone tell me if they are ready for use or if the test program I sent to the list contains some mistake? []s, Fernando Lozano _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

I took vs. mysql.h and at least main structure st_mysql differs!!! - This can cause very strange errors like RTE in writeln etc. Ofcourse u can compile & run demo prog. distributed with sources. It runs because of small database and little number of iterations. Simply said each iteration causes small memory leak - more records read/written (more iterations) ~ more leaks >> more strange errors :o(. Try to write bigger test program without FCL, using only mysql unit and you'll see ...

mysql.pp - current from linux sources (should be same for win32) - as there in sources isn't mentionet ssl extension I think lib is for 3.22.*
mysql.h - 3.23.49

-- Mirek Novak Anima Publishers CMS development http://www.auto.cz http://www.formule1.cz ISEEKYOU:1<one>9<four>9<nine>44<eight> GEsEm:+420603807838

Reply by email

Bernhard Steffen

Hi Florian & others,

I just checked with 3.23.51 and the TMySQL record has indeed new fields. Any opionions about updating the mysql import unit to match the 3.23.51 C headers?

I've done this about a year ago and sent those updated files to Michael, but somehow those changes didn't make their way into the release...

Since then I've updated those files again a little bit to make the 3.23 interface default (instead of having 3.21 the default interface), but that's it. It's truely only a adaption of the newer header files, nothing more, but works for me.

I'll attach the updated files to this e-mail. They're tested on a WinNT system with MySQL 3.23.34

HTH
Bernhard

Reply by email

Michael Van Canneyt
to Mirek Novak: I took vs. mysql.h and at least main structure st_mysql differs!!! - This can cause…
Mirek Novak wrote 32 lines
Fernando Lozano wrote: > Hi Mirek, > > > >>As for MySQL units for FPC this is is long-lasting problem and >>solution may be found in archive of this >>list. I've (2 years ago) got the same problem as U. It was caused by 2 things >> 1. library was written for client 3.21.* (this may changed) > > > It looks like now it was built for 3.23.*. At least the libmysql.dll from 3.23.32 worked fine for me. :-) > > But the FCL database classes still give me "Internal error". Can someone tell me if they are ready for use or if the test program I sent to the list contains some mistake? > > > []s, Fernando Lozano > > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > I took vs. mysql.h and at least main structure st_mysql differs!!! - This can cause very strange errors like RTE in writeln etc. Ofcourse u can compile & run demo prog. distributed with sources. It runs because of small database and little number of iterations. Simply said each iteration causes small memory leak - more records read/written (more iterations) ~ more leaks >> more strange errors :o(. Try to write bigger test program without FCL, using only mysql unit and you'll see ... mysql.pp - current from linux sources (should be same for win32) - as there in sources isn't mentionet ssl extension I think lib is for 3.22.* mysql.h - 3.23.49

I have the mysql 3.23 headers translated. I sent it to several people, asking whether they would inform me whether it works OK for them. I have had 1 reply.

I will commit the 3.23 version to cvs, and hope everything works.

Michael.

Reply by email