Click to See Complete Forum and Search --> : Query again, AnsiString
Leite33
September 20th, 2006, 02:17 AM
Hi
How i can use a query with ansistring value. For example:
AnsiString tom;
ADOQuery->SQL->Add("Select Names from Images where Name=tom");
but it brings me erros because of Ansistring. How can i do that;
HollyMatrix
September 21st, 2006, 08:37 PM
hi.
as i can guess. the Add(..) function needs a char* as a parameter. and you want to concat the "Select Names from Images where Name=" with the tom variable ???
if this is you case then you can convert your AnsiString to char* and then concate the two char*
The c_str() method of the AnsiString class returns
a const char* which can be used to read, but not
modify, the underlying string.
char* ch_tom = tom.c_str(). you have your char*
so you can use strcat_s() or the sprintf_s();
that's it.
wish this resolve your problem.
ncode
September 22nd, 2006, 07:36 AM
You can make query string this way:
ADOQuery->SQL->Add("Select Names from Images where Name='"+tom+"'");
However, in this case there might be an SQL error also.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.