Convert Char to LPCOLESTR using OLEDB.H

"Long, Matthew Jr. (Inland)" <[email protected]> Wed, 17 Apr 2002 17:59:47 -0500
Newsgroups gmane.comp.windows.devel.oledb.devel
Message-ID <[email protected]>
I'm trying to use OLEDB.H for the first time, and I got everything working
the way I want except for the T-SQL Command that I build on the fly. I have
a char variable that I append to using strcat. I need to convert this char
buffer to LPCOLESTR, I just don't know how, at least to where the
SetCommandText method will recononize the text in the buffer.

// My char buffer looks like this......

char m_cSQLCommand[6000];
strcat(m_cSQLCommand," SELECT COUNT(*) FROM DEVDTA.F5549018  ");


// The following is the OleDB Interface I'm using to pass my T-SQL buffer
string.
// This compiles with no errors but it doesn't work.

m_pCommandText->SetCommandText(DBGUID_DBSQL, (LPCOLESTR) m_szSQLCommand );


// Note if I do it this way it works! But this isn't going to work for me,
because I have to build this string on the fly, and the statement can be
different each time I loop through.

m_pCommandText->SetCommandText(DBGUID_DBSQL, OLESTR("SELECT COUNT(*) FROM
DEVDTA.F5549018 "));


Any ideas would be appreciated.....

VC 6.0 SP5 Win32

Thanks!

Matt