Newbie Question - Data conversion from tchar[] to VARIANT 
Author Message
 Newbie Question - Data conversion from tchar[] to VARIANT

Hello,
      I have the following source code:

STDMETHODIMP CTool::getSQL(BSTR bstrGroupID, BSTR bstrUserID, BSTR
bstrPassword, VARIANT *varXML)
{
 // TODO: Add your implementation code here
 _bstr_t tmpbstrGroupID(bstrGroupID);
 _bstr_t tmpbstrUserID(bstrUserID);
 _bstr_t tmpbstrPassword(bstrPassword);

 LPTSTR sGroupID = tmpbstrGroupID;
 LPTSTR sUserID = tmpbstrUserID;
 LPTSTR sPassword = tmpbstrPassword;
 LPTSTR sEntity='\0';
 TCHAR  sBuffer[2048];

 wsprintf(sBuffer,"select * from %s..users where group_id='%s' and
user_id='%s' and password='%s'",
  sEntity ,sGroupID,sUserID,sPassword);
.......

Quote:
}

sBuffer  has the correct result I want, how do I copy the value of sBuffer
into vaxXML?

Thanks in advance



Mon, 24 May 2004 08:37:22 GMT  
 Newbie Question - Data conversion from tchar[] to VARIANT
*varXML = _variant_t(sBuffer).Detach();

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Hello,
>       I have the following source code:

> STDMETHODIMP CTool::getSQL(BSTR bstrGroupID, BSTR bstrUserID, BSTR
> bstrPassword, VARIANT *varXML)
> {
>  // TODO: Add your implementation code here
>  _bstr_t tmpbstrGroupID(bstrGroupID);
>  _bstr_t tmpbstrUserID(bstrUserID);
>  _bstr_t tmpbstrPassword(bstrPassword);

>  LPTSTR sGroupID = tmpbstrGroupID;
>  LPTSTR sUserID = tmpbstrUserID;
>  LPTSTR sPassword = tmpbstrPassword;
>  LPTSTR sEntity='\0';
>  TCHAR  sBuffer[2048];

>  wsprintf(sBuffer,"select * from %s..users where group_id='%s' and
> user_id='%s' and password='%s'",
>   sEntity ,sGroupID,sUserID,sPassword);
> .......
> }

> sBuffer  has the correct result I want, how do I copy the value of sBuffer
> into vaxXML?

> Thanks in advance



Mon, 24 May 2004 08:59:45 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Stupid Question - Conversion of DOUBLE to TCHAR

2. conversion from variant data type

3. Newbie question - How do I tell if a TCHAR string is empty

4. Newbie question - How do I tell if a TCHAR string is empty

5. C# System.Object to Variant (Newbie Question #2)

6. VARIANT/BSTR IN VC Newbie question

7. VARIANT/BSTR IN VC Newbie question

8. TCHAR, etc. -- conversion macros in VCPP

9. conversion of TCHAR to an int for number comparison

10. Conversion from char to TCHAR

11. newbie question about type conversions

12. Newbie question - Endian conversion(?)

 

 
Powered by phpBB® Forum Software