Page 1 of 1

BCB6 always empty resultset returned

Posted: 25.11.2010, 11:40
by edwardvb
I cannot find a solution, and google is not really helpful too :(

I use Borland C++ Builder 6 together with the ZEOS library for communication with a MySQL database. Before I used the old ZEOS lib (6.1.5 stable) together with a MySQL4 database. Everything worked perfect, but I had to upgrade to MySQL 5.1 now, so that's why I upgraded to ZEOS library 6.6.6. If i test my application now, I come to the following:

- there is a connection with the database
- I can do an Insert() and a Post() and the records are perfectly added to the database

problem:
I perform a very simple query:

Code: Select all

SELECT myfield FROM mytable
This query gives about 800 records as a result in the MySQL command prompt. If I perform this query in my application, then I always get back 0 records. I tried all kind of things with object settings, database settings and I searched google, but I can't find any solution.

this is the code as it worked with ZEOSlib 6.1.5

Code: Select all

QueryString = "SELECT myfield FROM mytable";

ZQuery->Active = false;
ZQuery->SQL->Clear();
ZQuery->SQL->Add(QueryString);
ZQuery->Active = true;

AnsiString A = ZQuery->FieldByName("myfield")->AsString;
// A contains the right value


My latest version for now (with ZEOSlib 6.6.6), which is not working:

Code: Select all

QueryString = "SELECT myfield FROM mytable";

ZQuery->Active = false;
ZQuery->SQL->Clear();
ZQuery->SQL->Add(QueryString);
// ZQuery->RequestLive = true;
// ZQuery->Active = true;
ZQuery->Open();

AnsiString A = ZQuery->FieldByName("veld")->AsString;
// A is NULL
Any hints? I think I have to search for a solution in the database settings, but that is just "stupid" thinking.

maybe some other usefull info:
- ik tried to use both libmysql.dll and libmysql51.dll
- when I look at the content of ZQuery->SQL->Text then I see that the value is not only my QueryString, but a \r\n is added to it. I have no idea how to get rid of the \r\n on that point and i have no idea if it has anything to do with my problem.

Posted: 26.11.2010, 23:44
by mdaems
Hallo edwardvb,
I believe \r\n is just the reprentation of a new line (CRLF) in your debugger.

When seeing your example the first thing I see is that this can never work because you're mixing up 2 languages. Zeoslib isn't smart enough to translate the english 'myfield' to the dutch equivalent 'veld'. I suppose this is a small error when you translated your code for this forum? Anyway, I think this would result in an error like 'field not found' or something similar.
What's the result of 'Showmessage(ZQuery.RecordCount);' (Or the C-equivalent)?

Mark

Posted: 14.01.2011, 09:41
by edwardvb
to complete this topic: I solved this problem by setting the ShowRecordTypes property of the ZQuery-object to [usUnmodified,usModified,usInserted].