Pages

Thursday, December 29, 2011

How to convert tstringlist to comma separated string

For some reasons, we may need to convert TListString to a comma separated String. for example to create query that use 'in'. Below is the routine to do that :
var
   oSL : TStringlist;
   sBuffer : String;
begin
   oSL := TStringlist.Create;
   oSL.Add('A');
   oSL.Add('B');
   oSL.Add('C');
   sBuffer := Stringreplace(oSL.Text,Char(13)+Char(10),',',[rfReplaceAll]);
   Showmessage( sBuffer );
   oSL.Free;
end;

No comments:

Post a Comment

Don't Forget To Join Our Community
×
Widget