Concat number to bstr 
Author Message
 Concat number to bstr

Having problems with this code. Trying to append a value (short) to a
_bstr_t variable. newsId and docStatus are parameters defined as shorts.
ParamBuffer is _bstr_t("").

  paramBuffer.Append( (LPCSTR) newsId);
  paramBuffer.Append(L", ");
  paramBuffer.Append( (LPCSTR) docStatus);
  paramBuffer.Append(L", ");

Does not appear to be appending...

Thanks



Fri, 29 Apr 2005 11:49:38 GMT  
 Concat number to bstr
Robert,

Casting short  to LPCSTR doesn't convert it to a string.
Why not use sprintf or swprintf to format the data values to a string and
then convert it to _bstr_t?
wchar_t  buffer[200];
swprintf(buffer,L"%d, %d, ",newsId,docStatus);
_bstr_t paramBuffer(buffer);

Hope this helps.

Thank you,
Bobby Mattappally
Microsoft VC++/C# Team

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------

Quote:

>Subject: Concat number to bstr
>Date: Sun, 10 Nov 2002 22:49:38 -0500

>Having problems with this code. Trying to append a value (short) to a
>_bstr_t variable. newsId and docStatus are parameters defined as shorts.
>ParamBuffer is _bstr_t("").

>  paramBuffer.Append( (LPCSTR) newsId);
>  paramBuffer.Append(L", ");
>  paramBuffer.Append( (LPCSTR) docStatus);
>  paramBuffer.Append(L", ");

>Does not appear to be appending...

>Thanks



Fri, 29 Apr 2005 15:27:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. BSTR BSTR and BSTR

2. Convert a BSTR to a number?

3. BSTR concatenation and BSTR memory freeing

4. Problem with URI and String Concat

5. String* Concat

6. a C question, concat two strings!!!

7. StringBuilder vs. String.Concat

8. Help !!! Concat small array into large array

9. HELP: How to Concat files in C

10. concat a string

11. concat a string

12. Anyone seen speed decrease in CString concat in VC6 Debug

 

 
Powered by phpBB® Forum Software