Re: Working with LPCWSTR
Eric Evans <[email protected]> Tue, 15 Oct 2002 16:34:15 -0400
| Newsgroups | gmane.comp.windows.devel.oledb.devel |
|---|---|
| Message-ID | <[email protected]> |
This message is in MIME format. Since your mail reader does not understand
this format, some or all of this message may not be legible.
------_=_NextPart_001_01C2748A.3E095330
Content-Type: text/plain
Alan,
keep in mind the macro creates a static function and you are working with
static data there. I have something that works for switching commands
Oracle <> MSSQL
In Accessor Base
Class CSomeAccessor{
//provide custom implementation of GetDefaultCommand
//Altered : EEE 10/14/2002
static bool bSynOra;
static void SetOraTrue(){bSynOra=true;};
static void SetOraFalse(){bSynOra=false;};
typedef CInsertIImageAccessor _CommandClass; // For base
class reference to this one and only GetDefaultCommand class member
static HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand)
throw ()
{
if(bSynOra)//oracle syntax
*ppwszCommand = L"INSERT INTO faster.IImage
(IHUID,IHImageSetUID,IHKeywords, IHImage) VALUES( IHUIDSequence.NEXTVAL , ?,
? , NULL)";
else//MSSQL Syntax
*ppwszCommand = L"INSERT INTO faster.IImage
(IHImageSetUID, IHKeywords, IHImage) VALUES (?, ?, 0xAAAAAAA)";
return S_OK;
};
Outside Accessor Init Var:
//Altered : EEE 10/14/2002
bool CInsertIImageAccessor::bSynOra = true; //static data must be
initialized out side the definition.
Inside derving class
//Altered : EEE 10/14/2002
HRESULT Open(CSession* pSession,bool bOracleSyntax)
{
//Used for custom GetDefaultCommand : EEE
if(bOracleSyntax)
SetOraTrue();
else
SetOraFalse();
m_session = pSession;
return OpenRowset();
}
Might try adding to Accessor Base
static CString m_strNewStmt;
static CString GenerateDBMSSQL(Cstring strStmtToConvert){
m_strNewStmt = strStmtToConvert;
if(bSynOra)
{
...other conversion
m_strNewStmt.Replace("SUBSTRING","SUBSTR");
...other conversion
*ppwszCommand = A2W( (LPCTSTR)m_strNewStmt)
;//not sure if this is correct cast be you get idea
};
};
Call from: GetDefaultCommand:
static HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand)
throw ()
{
if(bSynOra)//oracle syntax
*ppwszCommand = GenerateDBMSSQL( "INSERT
INTO faster.IImage (IHUID,IHImageSetUID,IHKeywords, IHImage) VALUES(
IHUIDSequence.NEXTVAL , ?, ? , NULL)";
else//MSSQL Syntax
*ppwszCommand = GenerateDBMSSQL("INSERT INTO
faster.IImage (IHImageSetUID, IHKeywords, IHImage) VALUES (?, ?,
0xAAAAAAA)");
return S_OK;
};
Outside add initializer:
CString CInsertIImageAccessor::m_strNewStmt = "Statement Is
Blank";//garunteed to be there as long as MT access is not messing with it.
Regards,
Eric Evans
Systems Engineer
CCG Systems Inc.
612 Colonial Ave. Norfolk, Va. 23507-1806
Voicemail: 757-623-1700 Ext 121
Fax: 757-625-5114
Email: [email protected]
Web: <www.ccgsystems.com <www.ccgsystems.com> >
_________________________________________________
Trust us to be there
FASTER
_________________________________________________
-----Original Message-----
From: Alan Gamboa [mailto:[email protected] <mailto:[email protected]> ]
Sent: Tuesday, October 15, 2002 4:01 PM
To: [email protected]
Subject: Re: [OLEDB_DEV] Working with LPCWSTR
thanks,
this works to a point.
tracing through atldbcli.h, "wszCommand" contains the modified string;
however, after the following call (where it is creating the command and
setting the command text):
hr = CreateCommand(session);
hr returns S_OK, but "wszCommand" now contains "" - something blew it away.
still debugging now...
anyone have any idea why?
thanks.
Alan Gamboa
CCG Systems, Inc.
-----Original Message-----
From: Vagif Abilov [mailto:[email protected] <mailto:[email protected]> ]
Sent: Tuesday, October 15, 2002 1:41 PM
To: [email protected]
Subject: Re: [OLEDB_DEV] Working with LPCWSTR
First of all, if ParseString takes an LPCWSTR parameter, you can't change it
- LPCWSTR is a _const_ pointer to a wide character string.
Second, if your intention is to modify the string, on return you will get
another string, you can use LPWSTR either, it must be LPWSTR* (pointer to
pointer).
Third, why not let ParseString return a new string? Something like this:
inline CString ParseString(LPCWSTR pwszInput)
{
CString strOutput;
// do something
return strOutput;
}
Then if you need to convert return value to wide string, just call
T2W(ParseString(L"some string")).
Best regards
..................................
Vagif Abilov
Development team
[email protected]
Tel:+4723 33 25 79
Mob:+47928 21 221
Fax:+4723 33 25 71
..................................
Contopronto AS
Valkyriegaten 15
0366 Oslo, Norway
-----Original Message-----
From: OLEDB_DEV [mailto:[email protected]]On
<mailto:[email protected]]On> Behalf Of Alan Gamboa
Sent: 15. oktober 2002 19:14
To: [email protected]
Subject: [OLEDB_DEV] Working with LPCWSTR
I am so used to manipulating CString and char[] variables, I am having
problems working with LPCWSTR variables :)
in my accessor i have
MY_DEFINE_COMMAND_EX(CMyAccessor,L"SELECT blah, SUBSTRING(blah,1,1) FROM
tblBlah")
i have redefined DEFINE_COMMAND_EX as follows:
#define MY_DEFINE_COMMAND_EX(x, wszCommand) \
typedef x _CommandClass; \
static HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand) throw () \
{ \
ParseString(wszCommand); \
*ppwszCommand = wszCommand; \
return S_OK; \
}
here is ParseString():
inline void ParseString(LPCWSTR wszCommand)
{
//what i want to do!
CString s = wszCommand;
s.Replace("SUBSTRING","SUBSTR");
wszCommand = s;
}
I know the syntax above isn't exactly correct. Besides, I stepped through it
and wszCommand does not come back out.
any direction is appreciated.
Alan Gamboa
CCG Systems, Inc.
You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com <http://discuss.develop.com> .
You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com <http://discuss.develop.com> .
You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at
http://discuss.develop.com <http://discuss.develop.com> .
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
------_=_NextPart_001_01C2748A.3E095330
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3DUS-ASCII">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
5.5.2448.0">
<TITLE>RE: [OLEDB_DEV] Working with LPCWSTR</TITLE>
</HEAD>
<BODY>
<BR>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">Alan,</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> keep in mind the macro creates a =
static function and you are working with static data there. I =
have something that works for switching commands Oracle <> =
MSSQL</FONT></P>
<BR>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">In </FONT><FONT COLOR=3D"#FF0000" =
SIZE=3D2 FACE=3D"Arial">Accessor</FONT><FONT COLOR=3D"#FF0000" SIZE=3D2 =
FACE=3D"Arial"> Base</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Class CSomeAccessor{</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">//provide custom implementation of =
GetDefaultCommand</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">//Altered : EEE 10/14/2002</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static bool bSynOra;</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static void SetOraTrue(){bSynOra=3Dtrue;};</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static void SetOraFalse(){bSynOra=3Dfalse;};</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">typedef CInsertIImageAccessor _CommandClass; // For base =
class reference to this one and only GetDefaultCommand class =
member</FONT></P>
<P> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand) =
throw ()</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">{</FONT>
<BR> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">if(bSynOra)//oracle syntax</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">*ppwszCommand =3D L"INSERT INTO faster.IImage =
(IHUID,IHImageSetUID,IHKeywords, IHImage) VALUES( IHUIDSequence.NEXTVAL =
, ?, ? , NULL)";</FONT></P>
<P> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">else//MSSQL Syntax</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">*ppwszCommand =3D L"INSERT INTO faster.IImage =
(IHImageSetUID, IHKeywords, =
IHImage) VALUES (?, ?, 0xAAAAAAA)";</FONT></P>
<P> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">return S_OK;</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">};</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">Outside Accessor Init Var:</FONT>
</P>
<P> <FONT SIZE=3D2 =
FACE=3D"Arial">//Altered : EEE 10/14/2002</FONT>
<BR> <FONT SIZE=3D2 =
FACE=3D"Arial">bool CInsertIImageAccessor::bSynOra =3D true;</FONT> =
<FONT SIZE=3D2 FACE=3D"Arial">//static data must be initialized out =
side the definition.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Inside derving class </FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> //Altered : EEE =
10/14/2002</FONT>
<BR> <FONT SIZE=3D2 =
FACE=3D"Arial">HRESULT Open(CSession* pSession,bool =
bOracleSyntax)</FONT>
<BR> <FONT SIZE=3D2 =
FACE=3D"Arial">{</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> //Used for =
custom GetDefaultCommand : EEE</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> =
if(bOracleSyntax)</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> &nb=
sp; SetOraTrue();</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> else</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> &nb=
sp; SetOraFalse();</FONT>
</P>
<P><FONT SIZE=3D2 =
FACE=3D"Arial"> m_session =3D =
pSession;</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">return OpenRowset();</FONT>
<BR> <FONT SIZE=3D2 =
FACE=3D"Arial">}</FONT>
</P>
<P> <FONT SIZE=3D2 =
FACE=3D"Arial">Might try</FONT> <FONT SIZE=3D2 FACE=3D"Arial">adding to =
</FONT><FONT COLOR=3D"#FF0000" SIZE=3D2 FACE=3D"Arial">Accessor =
Base</FONT>
</P>
<P> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static CString</FONT> <FONT SIZE=3D2 =
FACE=3D"Arial">m_</FONT><FONT SIZE=3D2 FACE=3D"Arial">str</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">NewStmt;</FONT>
</P>
<P> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static CString GenerateDBMSSQL(Cstring =
strStmtToConvert){</FONT>
<BR> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">m_</FONT><FONT SIZE=3D2 FACE=3D"Arial">str</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">NewStmt =3D strStmtToConvert;</FONT>
</P>
<P> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">if(</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">bSynOra</FONT><FONT SIZE=3D2 FACE=3D"Arial">)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
=
{</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">...other conversion</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">m_</FONT><FONT SIZE=3D2 FACE=3D"Arial">str</FONT><FONT =
SIZE=3D2 =
FACE=3D"Arial">NewStmt.Replace("SUBSTRING","SUBSTR")=
;</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">...other conversion</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">*ppwszCommand</FONT><FONT SIZE=3D2 FACE=3D"Arial"> =3D =
A2W( (LPCTSTR)m_</FONT><FONT SIZE=3D2 FACE=3D"Arial">str</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">NewStmt) ;//not sure if this is correct cast be =
you get idea</FONT></P>
<P> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">};</FONT>
</P>
<P> =
<FONT SIZE=3D2 =
FACE=3D"Arial">};</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Call from: GetDefaultCommand:</FONT>
</P>
<P> =
<FONT SIZE=3D2 =
FACE=3D"Arial">static HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand) =
throw ()</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">{</FONT>
<BR> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">if(bSynOra)//oracle syntax</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">*ppwszCommand =3D</FONT><FONT SIZE=3D2 FACE=3D"Arial"> =
GenerateDBMSSQL(</FONT><FONT SIZE=3D2 FACE=3D"Arial"> "INSERT INTO =
faster.IImage (IHUID,IHImageSetUID,IHKeywords, IHImage) VALUES( =
IHUIDSequence.NEXTVAL , ?, ? , NULL)";</FONT></P>
<P> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">else//MSSQL Syntax</FONT>
<BR> =
=
=
<FONT SIZE=3D2 =
FACE=3D"Arial">*ppwszCommand =3D</FONT> <FONT SIZE=3D2 =
FACE=3D"Arial">GenerateDBMSSQL(</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">"INSERT INTO faster.IImage (IHImageSetUID, =
IHKeywords, IHImage) VALUES (?, ?, 0xAAAAAAA)"</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">);</FONT></P>
<P> =
=
<FONT SIZE=3D2 =
FACE=3D"Arial">return S_OK;</FONT>
<BR> =
<FONT SIZE=3D2 =
FACE=3D"Arial">};</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">Outsid</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">e add initializer:</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">CString =
CInsertIImageAccessor</FONT><FONT SIZE=3D2 =
FACE=3D"Arial">::m_</FONT><FONT SIZE=3D2 FACE=3D"Arial">str</FONT><FONT =
SIZE=3D2 FACE=3D"Arial">NewStmt =3D "Statement Is =
Blank";//garunteed to be there as long as MT access is not messing =
with it.</FONT></P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">Regards,</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> Eric Evans</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> Systems Engineer</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> CCG Systems Inc.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> 612 Colonial Ave. Norfolk, Va. =
23507-1806</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> Voicemail: 757-623-1700 Ext =
121</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> Fax:  =
; 757-625-5114</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> Email: &nb=
sp; [email protected]</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> Web:  =
; <</FONT><A HREF=3D"www.ccgsystems.com"><U><FONT =
COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">www.ccgsystems.com</FONT></U></A><FONT SIZE=3D2 =
FACE=3D"Arial">></FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">_________________________________________________</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> Trust us to =
be there</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> &nb=
sp; &nb=
sp; &nb=
sp; &nb=
sp; &nb=
sp; =
FASTER</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">_________________________________________________</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">-----Original Message-----</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">From: Alan Gamboa [</FONT><A =
HREF=3D"mailto:[email protected]"><U><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">mailto:[email protected]</FONT></U></A><FONT SIZE=3D2 =
FACE=3D"Arial">]</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Sent: Tuesday, October 15, 2002 4:01 =
PM</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">To: =
[email protected]</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Subject: Re: [OLEDB_DEV] Working with =
LPCWSTR</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">thanks,</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">this works to a point.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">tracing through atldbcli.h, =
"wszCommand" contains the modified string; however, after the =
following call (where it is creating the command and setting the =
command text):</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial"> </FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> hr =3D =
CreateCommand(session);</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">hr returns S_OK, but =
"wszCommand" now contains "" - something blew it =
away. still debugging now...</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">anyone have any idea why?</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">thanks.</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Alan Gamboa</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">CCG Systems, Inc.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">-----Original Message-----</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">From: Vagif Abilov [</FONT><A =
HREF=3D"mailto:[email protected]"><U><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">mailto:[email protected]</FONT></U></A><FONT SIZE=3D2 =
FACE=3D"Arial">]</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Sent: Tuesday, October 15, 2002 1:41 =
PM</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">To: =
[email protected]</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Subject: Re: [OLEDB_DEV] Working with =
LPCWSTR</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">First of all, if ParseString takes an =
LPCWSTR parameter, you can't change it - LPCWSTR is a _const_ pointer =
to a wide character string.</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Second, if your intention is to modify =
the string, on return you will get another string, you can use LPWSTR =
either, it must be LPWSTR* (pointer to pointer).</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Third, why not let ParseString return =
a new string? Something like this:</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">inline CString ParseString(LPCWSTR =
pwszInput)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> CString =
strOutput;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> // do =
something</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> return =
strOutput;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Then if you need to convert return =
value to wide string, just call T2W(ParseString(L"some =
string")).</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Best regards</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 =
FACE=3D"Arial">..................................</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Vagif Abilov</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Development team</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">[email protected]</FONT>
</P>
<P><FONT SIZE=3D2 FACE=3D"Arial">Tel:+4723 33 25 79</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Mob:+47928 21 221</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Fax:+4723 33 25 71</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">..................................</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Contopronto AS</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Valkyriegaten 15</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">0366 Oslo, Norway</FONT>
</P>
<BR>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">-----Original Message-----</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">From: OLEDB_DEV [</FONT><A =
HREF=3D"mailto:[email protected]]On"><U><FONT =
COLOR=3D"#0000FF" SIZE=3D2 FACE=3D"Arial">mailto:[email protected]=
OP.COM]On</FONT></U></A><FONT SIZE=3D2 FACE=3D"Arial"> Behalf Of Alan =
Gamboa</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Sent: 15. oktober 2002 19:14</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">To: =
[email protected]</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Subject: [OLEDB_DEV] Working with =
LPCWSTR</FONT>
</P>
<BR>
<P><FONT SIZE=3D2 FACE=3D"Arial">I am so used to manipulating CString =
and char[] variables, I am having problems working with LPCWSTR =
variables :)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">in my accessor i have</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial">MY_DEFINE_COMMAND_EX(CMyAccessor,L"SELECT blah, =
SUBSTRING(blah,1,1) FROM tblBlah")</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">i have redefined DEFINE_COMMAND_EX as =
follows:</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">#define MY_DEFINE_COMMAND_EX(x, =
wszCommand) \</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> typedef x =
_CommandClass; \</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> static =
HRESULT GetDefaultCommand(LPCWSTR* ppwszCommand) throw () \</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> { \</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> &nb=
sp; ParseString(wszCommand); \</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> &nb=
sp; *ppwszCommand =3D wszCommand; =
\</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> &nb=
sp; return S_OK; \</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> }</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">here is ParseString():</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">inline void ParseString(LPCWSTR =
wszCommand)</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">{</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> //what i want =
to do!</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> CString s =3D =
wszCommand;</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> =
s.Replace("SUBSTRING","SUBSTR");</FONT>
<BR><FONT SIZE=3D2 =
FACE=3D"Arial"> wszCommand =
=3D s;</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">}</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">I know the syntax above isn't exactly =
correct. Besides, I stepped through it and wszCommand does not come =
back out.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">any direction is appreciated.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">Alan Gamboa</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">CCG Systems, Inc.</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial"> =
</FONT>
<BR><FONT SIZE=3D2 FACE=3D"Arial">You can read messages from the =
OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other =
DevelopMentor lists at </FONT><A =
HREF=3D"http://discuss.develop.com"><U><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">http://discuss.develop.com</FONT></U></A><FONT SIZE=3D2 =
FACE=3D"Arial">.</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">You can read messages from the =
OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other =
DevelopMentor lists at </FONT><A =
HREF=3D"http://discuss.develop.com"><U><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">http://discuss.develop.com</FONT></U></A><FONT SIZE=3D2 =
FACE=3D"Arial">.</FONT></P>
<P><FONT SIZE=3D2 FACE=3D"Arial">You can read messages from the =
OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or subscribe to other =
DevelopMentor lists at </FONT><A =
HREF=3D"http://discuss.develop.com"><U><FONT COLOR=3D"#0000FF" SIZE=3D2 =
FACE=3D"Arial">http://discuss.develop.com</FONT></U></A><FONT SIZE=3D2 =
FACE=3D"Arial">. </FONT></P>
</BODY>
You can read messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at http://discuss.develop.com.
</HTML>
------_=_NextPart_001_01C2748A.3E095330--