Board index » delphi » Different results between IBConsole and C++Builder

Different results between IBConsole and C++Builder


2007-07-16 12:04:39 AM
delphi253
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 am 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
 
 

Re:Different results between IBConsole and C++Builder

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
"pcerdaz" <XXXX@XXXXX.COM>escribi?en el mensaje
Quote
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 am 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

 

Re:Different results between IBConsole and C++Builder

Any chance you have any TFields for your TQuery defined?
pcerdaz writes:
Quote
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 am 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