Discussion:
Different results between IBConsole and C++Builder
(too old to reply)
pcerdaz
2007-07-15 16:04:39 UTC
Permalink
Hello,

I have a problem with a simple SLQ command on C++Builder 2006 because it
does not recognize the field where I need some information. I'm using the
following code in the IBConsole with correct answer of CantidadUsuarios = 1:

select count(*) as CantidadUsuarios from USUARIOS where
USUARIOS.CodigoUsuario = 21

But in the C++Builder where I used the following code, I have an error
message that says "Project nnn raised an exception class EDatabaseError with
message 'IBDS_Usuarios: Field 'CODIGOUSUARIO' not found'":

Sentencia_SQL = "select count(*) as CantidadUsuarios from USUARIOS where
USUARIOS.CodigoUsuario = ";
Sentencia_SQL += String(Valor);
DMTEC->IBDS_Usuarios->SelectSQL->Text = Sentencia_SQL;
DMTEC->IBDS_Usuarios->Active = true;

What could be wrong? Any idea would be gratefully.

pcerdaz
pcerdaz
2007-07-16 15:22:45 UTC
Permalink
I'm making different tests and probably the problem is the "count(*) as
CantidadUsuarios" because when I change this part of SQL to "*" then it
works well, but I haven't the aggregate number that I need.

How can I obtain the number of registers that this modified SQL will give?

Do you know why this "count(*) as CantidadUsuarios" is not recognize in the
C++Builder? Remember that in IBConsole this SQL works well.

Thank you,
pcerdaz
Post by pcerdaz
Hello,
I have a problem with a simple SLQ command on C++Builder 2006 because it
does not recognize the field where I need some information. I'm using the
select count(*) as CantidadUsuarios from USUARIOS where
USUARIOS.CodigoUsuario = 21
But in the C++Builder where I used the following code, I have an error
message that says "Project nnn raised an exception class EDatabaseError
Sentencia_SQL = "select count(*) as CantidadUsuarios from USUARIOS where
USUARIOS.CodigoUsuario = ";
Sentencia_SQL += String(Valor);
DMTEC->IBDS_Usuarios->SelectSQL->Text = Sentencia_SQL;
DMTEC->IBDS_Usuarios->Active = true;
What could be wrong? Any idea would be gratefully.
pcerdaz
Quinn Wildman (CodeGear Developer Support)
2007-07-20 19:29:55 UTC
Permalink
Any chance you have any TFields for your TQuery defined?
Post by pcerdaz
Hello,
I have a problem with a simple SLQ command on C++Builder 2006 because it
does not recognize the field where I need some information. I'm using the
select count(*) as CantidadUsuarios from USUARIOS where
USUARIOS.CodigoUsuario = 21
But in the C++Builder where I used the following code, I have an error
message that says "Project nnn raised an exception class EDatabaseError with
Sentencia_SQL = "select count(*) as CantidadUsuarios from USUARIOS where
USUARIOS.CodigoUsuario = ";
Sentencia_SQL += String(Valor);
DMTEC->IBDS_Usuarios->SelectSQL->Text = Sentencia_SQL;
DMTEC->IBDS_Usuarios->Active = true;
What could be wrong? Any idea would be gratefully.
pcerdaz
Loading...