BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

AnsiString, Spaces and TQuery::SQL

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Raul Lorenzo
Guest





PostPosted: Thu Feb 09, 2006 2:03 pm    Post subject: AnsiString, Spaces and TQuery::SQL Reply with quote



Hi,

I attached the code file to see better. See in borland.public.attachments

I have this code which works fine with BCB6, but with BDS2006 BDE tells
me that 1 parameter is expected. I ran the SQL Query directly to the
database and it works well, so....

I think that the error could be in the line between /********/ , exactly
in -> _concepto+\" \"+B.desc_ <-
I need to concatenate an space to show it in the query result, but why
now crashes?

Note: To execute in access I need to change \" \" for \' \' , instead
errors.
Back to top
Darko Miletic
Guest





PostPosted: Thu Feb 09, 2006 3:03 pm    Post subject: Re: AnsiString, Spaces and TQuery::SQL Reply with quote



Raul Lorenzo wrote:
Quote:
Hi,

I attached the code file to see better. See in borland.public.attachments

I have this code which works fine with BCB6, but with BDS2006 BDE tells
me that 1 parameter is expected. I ran the SQL Query directly to the
database and it works well, so....

I think that the error could be in the line between /********/ , exactly
in -> _concepto+\" \"+B.desc_ <-
I need to concatenate an space to show it in the query result, but why
now crashes?

Note: To execute in access I need to change \" \" for \' \' , instead
errors.

If that is the case then the problem is in VCL database component and
not in AnsiString. Therefore direct your question to either one of
borland.public.cppbuilder.database groups or to
borland.public.cppbuilder.vcl.components.using

Darko

BTW you should not append strings like that because it is not optimal.
This is better/faster way:

AnsiString SQL_Detail1("(select A.desc_concepto, A.importe");
SQL_Detail1+=" from ";
SQL_Detail1+=t_concepto;
SQL_Detail1+=" as A,";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=" where ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_alum=";
SQL_Detail1+=alumno;
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".mes=";
SQL_Detail1+=Get_Alumno_Mes();
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_concepto=A.id_concepto";
SQL_Detail1+=" and A.concepto_detalle is NULL)";
/**********************/
SQL_Detail1+=" union (select A.desc_concepto+\" \"+B.desc_concepto,
B.importe";
/**********************/
SQL_Detail1+=" from ";
SQL_Detail1+=t_concepto;
SQL_Detail1+=" as A,";
SQL_Detail1+=t_concepto;
SQL_Detail1+=" as B,";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=" where ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_alum=";
SQL_Detail1+=alumno;
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".mes=";
SQL_Detail1+=Get_Alumno_Mes();
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_concepto=B.id_concepto";
SQL_Detail1+=" and A.id_concepto=B.concepto_detalle)";
Back to top
Raul Lorenzo
Guest





PostPosted: Wed Feb 15, 2006 8:03 pm    Post subject: Re: AnsiString, Spaces and TQuery::SQL Reply with quote



Thanks, now I got to make query to database, I will try to optimize that
code like you told me.

Darko Miletic escribió:
Quote:
Raul Lorenzo wrote:
Hi,

I attached the code file to see better. See in borland.public.attachments

I have this code which works fine with BCB6, but with BDS2006 BDE tells
me that 1 parameter is expected. I ran the SQL Query directly to the
database and it works well, so....

I think that the error could be in the line between /********/ , exactly
in -> _concepto+\" \"+B.desc_ <-
I need to concatenate an space to show it in the query result, but why
now crashes?

Note: To execute in access I need to change \" \" for \' \' , instead
errors.

If that is the case then the problem is in VCL database component and
not in AnsiString. Therefore direct your question to either one of
borland.public.cppbuilder.database groups or to
borland.public.cppbuilder.vcl.components.using

Darko

BTW you should not append strings like that because it is not optimal.
This is better/faster way:

AnsiString SQL_Detail1("(select A.desc_concepto, A.importe");
SQL_Detail1+=" from ";
SQL_Detail1+=t_concepto;
SQL_Detail1+=" as A,";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=" where ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_alum=";
SQL_Detail1+=alumno;
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".mes=";
SQL_Detail1+=Get_Alumno_Mes();
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_concepto=A.id_concepto";
SQL_Detail1+=" and A.concepto_detalle is NULL)";
/**********************/
SQL_Detail1+=" union (select A.desc_concepto+\" \"+B.desc_concepto,
B.importe";
/**********************/
SQL_Detail1+=" from ";
SQL_Detail1+=t_concepto;
SQL_Detail1+=" as A,";
SQL_Detail1+=t_concepto;
SQL_Detail1+=" as B,";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=" where ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_alum=";
SQL_Detail1+=alumno;
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".mes=";
SQL_Detail1+=Get_Alumno_Mes();
SQL_Detail1+=" and ";
SQL_Detail1+=t_alum_con_recmensual;
SQL_Detail1+=".id_concepto=B.id_concepto";
SQL_Detail1+=" and A.id_concepto=B.concepto_detalle)";
Back to top
Raul Lorenzo
Guest





PostPosted: Wed Feb 15, 2006 8:03 pm    Post subject: Re: AnsiString, Spaces and TQuery::SQL Reply with quote

I solved the problem, I think something changed from previous versions
to BDS2006 in TQuery, so I changed _concepto+\" \"+B.desc_ to
_concepto+\' \'+B.desc_ and now works like before.


Raul Lorenzo escribió:
Quote:
Hi,

I attached the code file to see better. See in borland.public.attachments

I have this code which works fine with BCB6, but with BDS2006 BDE tells
me that 1 parameter is expected. I ran the SQL Query directly to the
database and it works well, so....

I think that the error could be in the line between /********/ , exactly
in -> _concepto+\" \"+B.desc_ <-
I need to concatenate an space to show it in the query result, but why
now crashes?

Note: To execute in access I need to change \" \" for \' \' , instead
errors.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.