Page 1 of 1

[solved] ZeosLib version and SQLite error

Posted: 06.12.2012, 14:16
by jjeffman
Hello.

I am posting this topic in this forum because I do not know how to check which ZeosLib version I have installed on C++Builder 6.0 Professional Edition.

I have chosen sqlite-3 Protocol for the TZConnection component.

The SQL select command bellow raises an EZSQLEception (SQL logic error or missing database) when I call the Open method, but it does not raise any exception at design time ( data shownn in a grid!) and runs fine on "SQLite Expert Personal 3":

[SQL]
SELECT usr.apuser, IFNULL( usr.name, usr.username ) AS name
FROM apuser usr
WHERE
UPPER(usr.username) = UPPER(:usrname) AND
(usr.password IS NULL
OR UPPER(usr.password) = UPPER(:pwd)) AND
usr.status = 'S'
[/SQL]

What am I doing wrong ?

Thanks a lot.

Jayme Jeffman Filho

Posted: 06.12.2012, 14:34
by EgonHugeist
jjeffman,

did you assign the Parameters? In ZClasses.pas is a constant which declares the Major, Minior and Release Vesion+ stable/beta/alfa. But no SVN version is availabe..

Posted: 06.12.2012, 14:57
by jjeffman
Thank you for answering.

Yes I did.

Parameter "pwd" should may have a null value, and it works at design time.

Code: Select all

   QAppLogin->Close();
    QAppLogin->ParamByName("pwd")->Clear();
    QAppLogin->ParamByName("usrname")->AsString = cAppUser;
    if(cAppPwd.Length() > 0)
      QAppLogin->ParamByName("pwd")->AsString = cAppPwd;
    QAppLogin->Open();
I was not able to check if the value assignment is working because Zeos components do not behave the same way CBuilders' do.

My Zeos version is ZEOS_VERSION = '6.6.6-stable';

Posted: 06.12.2012, 15:50
by jjeffman
I have found the problem, at runtime the column name "password" is not permited although it runs perfectly at design time. Perhaps it is a component bug because SQLite allows naming a column as "password".

Is there a way around of this without changing the column name ? Like MySQL putting the column name between special quotes.

I have tried all options given at http://www.sqlite.org/lang_keywords.html, all of them are suported by "SQLite Express Personal 3" but none of them has worked on TZReadOnlyQuery.

Thank you very much.

Posted: 06.12.2012, 22:39
by EgonHugeist
jjeffman,

hmm currently i can't see what should be going wrong. IMHO your code should work. Which compiler do you use? Can you provide a little template app which points me to this issue? Also would it be a good idea to update to Zeos7-7.0.1-Beta or SVN. Then we are on the same bandwidth..

Posted: 07.12.2012, 18:33
by jjeffman
I have made a simple C++Builder application using the same SQLite table structure which I have failed on perform a SQL select to perform user login to the application.

When testing the application I saw it was working perfectly. The diferences are :

1. I have said it works at design time. The SQL parameters are set through the IDE, not by code;

2. On the new application I am using the Borland's "InputQuery" function to get the SQL parameters;

So the problem must be on the way I am passing parameters at runtime on the old application. I will go after the solution checking the parameters values. They can have been corrupted by the way I am getting them.

Thank you very much.

Kind regards.

Posted: 07.12.2012, 19:36
by jjeffman
Hi,

The problem was the code to get the network user using Windows API GetUserName function which returns a buffer ended by a '\0' character.

I have cut the '\0' when present and the application is working fine.

Thank you very much.

Kind regards.

Posted: 07.12.2012, 20:11
by EgonHugeist
jjeffman,

:up: Allways nice to heare it works!