Re: AW: [OLEDB_DEV] OLE DB Consumer Templates

Erik Valdes <[email protected]> Thu, 9 Jan 2003 15:25:15 -0700
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_01C2B82D.FB6A4500
Content-Type: text/plain

Hi Duncan,



I'm getting compilation errors.  Where are bClearOnly and pColumnNames
coming from?



Erik



-----Original Message-----
From: Duncan Smith [mailto:[email protected]]
Sent: Thursday, January 09, 2003 2:17 PM
To: [email protected]
Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer Templates



Hi Erik,



According to the OLE DB documentation for the DBBINDING dwMemOwner field:
"For bindings in parameter accessors, consumer-owned memory must always be
used."



I also use the same type of accessor entry (COLUMN_ENTRY_EX_BYREF(n,
DBTYPE_STR | DBTYPE_BYREF...)) when getting a rowset containing a column
with the XML data. For bindings in row accessors, it gives the client
control over when the memory is to be freed.



Duncan



-----Original Message-----
From: Erik Valdes [mailto:[email protected]]
Sent: Thursday, January 09, 2003 4:05 PM
To: [email protected]
Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer Templates



Hi Duncan,



You've gone one step further than I expected.  I'm not sure I understand the
relevance of who owns the memory.  However, I had not tried using
DBTYPE_BYREF at all so that is something I need to try.  Why is the memory
owner important for this issue?



Thanks,

Erik



-----Original Message-----
From: Duncan Smith [mailto:[email protected]]
Sent: Thursday, January 09, 2003 1:21 PM
To: [email protected]
Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer Templates



I encountered this exact issue. I wanted to pass a string buffer containing
XML data to the provider using client-owned memory. The OLE DB data type I
use is DBTYPE_STR | DBTYPE_BYREF. Using the standard OLE DB consumer
template macros will result in this being provider-owned memory (see
CAccessorBase::Bind in atldbcli.h). So I created my own CAccessorBase type
class (called CAccessorBaseEx below) with 2 static methods and created my
own bind macro as follows:



// This macro is to be used in place of _COLUMN_ENTRY_CODE (in atldbcli.h)
for a parameter or

// column whose type has the DBTYPE_BYREF bit set. CAccessorBase::Bind
always sets dwMemOwner

// to DBMEMOWNER_PROVIDEROWNED if the DBTYPE_BYREF bit set. This macro
changes that behavior by

// setting dwMemOwner to the value passed as the last macro parameter.

// Use COLUMN_ENTRY_EX_BYREF instead of COLUMN_ENTRY_EX (in atldbcli.h) for
DBTYPE_BYREF entries.

#define _COLUMN_ENTRY_CODE_BYREF(nOrdinal, wType, nLength, nPrecision,
nScale, dataOffset, lengthOffset, statusOffset, dwMemOwner) \

      if (pBuffer != NULL) \

      { \

            if (!bClearOnly) \

                  CAccessorBaseEx::FreeType(wType, pBuffer + dataOffset,
dwMemOwner); \

            memset(pBuffer + dataOffset, 0, nLength); \

      } \

      else if (pBinding != NULL) \

      { \

            ATLASSERT( pColumnNames != NULL ); \

            *pColumnNames = NULL; \

            CAccessorBaseEx::Bind(pBinding, nOrdinal, wType, nLength,
nPrecision, nScale, eParamIO, \

                  dataOffset, lengthOffset, statusOffset, NULL, dwMemOwner);
\

            pColumnNames++; \

            pBinding++; \

      } \

      nColumns++;



#define COLUMN_ENTRY_EX_BYREF(nOrdinal, wType, nLength, nPrecision, nScale,
data, length, status, dwMemOwner) \

      _COLUMN_ENTRY_CODE_BYREF(nOrdinal, wType, nLength, nPrecision, nScale,
offsetbuf(data), offsetbuf(length), offsetbuf(status), dwMemOwner)





class CAccessorBaseEx

{

public:

      static void Bind(DBBINDING* pBinding, ULONG nOrdinal, DBTYPE wType,

            ULONG nLength, BYTE nPrecision, BYTE nScale, DBPARAMIO eParamIO,

            ULONG nDataOffset, ULONG nLengthOffset = NULL, ULONG
nStatusOffset = NULL,

            DBOBJECT* pdbobject = NULL, DBMEMOWNER dwMemOwner =
DBMEMOWNER_CLIENTOWNED) throw()

      {

            ATL::CAccessorBase::Bind(

                  pBinding,

                  nOrdinal,

                  wType,

                  nLength,

                  nPrecision,

                  nScale,

                  eParamIO,

                  nDataOffset,

                  nLengthOffset,

                  nStatusOffset,

                  pdbobject);



            pBinding->dwMemOwner = dwMemOwner;

      }



      static inline void FreeType(DBTYPE wType, BYTE* pValue, DBMEMOWNER
dwMemOwner) throw()

      {

            if ((wType & DBTYPE_BYREF) && (dwMemOwner ==
DBMEMOWNER_CLIENTOWNED))

            {

                  void * pData = *(void **)pValue;



                  if (pData != NULL)

                        CoTaskMemFree(pData);

            }

            else

                  ATL::CAccessorBase::FreeType(wType, pValue);

      }

};



Then the accessor I used has the following (the SQL Server data type I am
using is text):



      char *      m_pszData;

      DBLENGTH    m_DataLength;

      DBSTATUS    m_DataStatus;

...

COLUMN_ENTRY_EX_BYREF(5, DBTYPE_STR | DBTYPE_BYREF, sizeof(char *), 0, 0,
m_pszData, m_DataLength, m_DataStatus, DBMEMOWNER_CLIENTOWNED)



Hope this helps.

Duncan Smith





-----Original Message-----
From: Erik Valdes [mailto:[email protected]]
Sent: Thursday, January 09, 2003 1:17 PM
To: [email protected]
Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer Templates



Hi,

I see what you mean about MS recommending the storage object way.  I've
found a lot of articles describing that.  However, I'm having trouble
finding anything that gives an example of how to do the in-memory way.
Perhaps someone could point me to an example or a how-to document?  I'd
really appreciate it.

Thanks,
Erik

-----Original Message-----
From: Yuancai Ye [mailto:[email protected] <mailto:[email protected]> ]
Sent: Thursday, January 09, 2003 9:57 AM
To: [email protected]
Subject: Re: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer Templates

Hi,
    MS recommends us to use storage object for sending
a BLOB into a data source. However, as I tested, this
way is bad in many cases since your code needs to
create a store object and database needs to recover
binnary data from the store object. You'd better use
in-memory way to send BLOB for faster speed. With use
of in-memory way, the previous two extra steps are
avoided. Therefore, in-memory way is faster. That is
my guess. Test it yourself.

Regards,

Yuancai (Charlie) Ye

--- Rudolf Wiener <[email protected]> wrote:
> Erik,
>
> For reading and writing blobs, which is what you're
> in fact using, I use the
> technologies recommended and stream the data with a
> storage object. The
> macro I use in the accessor is
> BLOB_ENTRY_LENGTH_STATUS. I'm not sure if
> this is the best way to do it because I have the
> impression it slows things
> down a bit. But I haven't had the time yet to look
> into faster alternatives.
>
> If you like I can send you excerpts from my app's
> code.
>
> Regards
> Rudi
>
>   -----Urspr&#40689;gliche Nachricht-----
>   Von: OLEDB_DEV
> [mailto:[email protected]
<mailto:[email protected]> ]Im Auftrag von
> Erik
> Valdes
>   Gesendet: Donnerstag, 09. J&#37592;ner 2003 17:22
>   An: [email protected]
>   Betreff: Re: [OLEDB_DEV] OLE DB Consumer Templates
>
>
>   The reason I can't allocate on the stack is that
> my variable can be any
> length.  It essentially boils down to the string
> representation of an xml
> file.  That file can be any size.  When I pass it to
> my SP, the sp's
> parameter is ntext (to allow for any size).   What
> do people do when they
> want to pass XML of unknown length to a SQL Server
> stored procedure?
>
>
>
>   -----Original Message-----
>   From: Peter Moss [mailto:[email protected] <mailto:[email protected]> ]
>   Sent: Thursday, January 09, 2003 7:58 AM
>   To: [email protected]
>   Subject: Re: [OLEDB_DEV] OLE DB Consumer Templates
>
>
>
>   If I remember right, you can't use the macros for
> heap-allocated
> variables.  If you dig into the macro definitions, I
> believe you will find
> that pointers offset from the beginning of 'this'
> are used.  Thus, a
> heap-allocated variable like m_WorkRequest will not
> work.
>
>
>
>   Why can't you just allocate a TCHAR on the stack
> frame of the object, ie,
>
>
>
>   TCHAR m_WorkRequest[257];     // Or 1 + the size
> of your SP parameter size
>
>
>
>   Then you can just use COLUMN_ENTRY.
>
>
>
>   HTH,
>
>   Peter
>
>     -----Original Message-----
>     From: OLEDB_DEV
> [mailto:[email protected]
<mailto:[email protected]> ]On Behalf Of
> Erik
> Valdes
>     Sent: Wednesday, January 08, 2003 5:22 PM
>     To: [email protected]
>     Subject: [OLEDB_DEV] OLE DB Consumer Templates
>
>     I'm having trouble implementing an accessor.
> I'm trying to use a
> variable (m_WorkRequest) that's dynamically
> allocated as the variable that's
> bound to a parameter in my accessor (commented line
> below).   The reason I
> need it to be dynamic is that it is XML and can be
> any length.  The stored
> proc's parameter is of ntext type to handle the
> variable length.  However, I
> don't know at compile time how big to make the
> buffer for my parameter in my
> accessor.  What's the proper way to do this?  I've
> tried COLUMN_ENTRY
> (access violation), COLUMN_ENTRY_LENGTH (different
> variations produce
> different errors, but basically I can't set the
> length),
> COLUMN_ENTRY_TYPE_SIZE (similar problems as the
> previous).  I'm running out
> of ideas now.  The code below is just one of many,
> many variations I've
> tried.
>
>
>
>
>
>     class CAddWorkRequest
>
>     {
>
>     public:
>
>        CAddWorkRequest() STD_INIT
>
>        ~CAddWorkRequest()
>
>        {
>
>           if (m_WorkRequest)
>
>              delete [] m_WorkRequest;
>
>        }
>
>        LONG m_RETURNVALUE;
>
>        LPTSTR m_WorkRequest;
>
>        LONG m_lLength;
>
>
>
>        void SetStringParam(LPCTSTR szString,int
> cBytes)
>
>        {
>
>           m_WorkRequest = (LPTSTR) new
> TCHAR[cBytes];
>
>           _tcsncpy(m_WorkRequest,szString,cBytes);
>
>           m_lLength = _tcslen(m_WorkRequest);
>
>        })
>
>
>
>     BEGIN_PARAM_MAP(CAddWorkRequest)
>
>        SET_PARAM_TYPE(DBPARAMIO_OUTPUT)
>
>        COLUMN_ENTRY(1, m_RETURNVALUE)
>
>        SET_PARAM_TYPE(DBPARAMIO_INPUT)
>
>     //
>
COLUMN_ENTRY_TYPE_SIZE(2,DBTYPE_STR,_tcslen(m_WorkRequest),
> m_WorkRequest)
>
>
>
>
>
>     END_PARAM_MAP()
>
>
>
>     DEFINE_COMMAND(CAddWorkRequest, _T("{ ? = CALL
> dbo.AddWorkRequest;1
> (?) }"))
>
>
>
>     };
>
>
>
>     class CAddWorkRequestCommand : public
> CBsDbCommand<CAddWorkRequest>
>
>     {
>
>     };
>
>
>
>     foo (LPTSTR szWor)
>
>     {
>
>
=== message truncated ===



__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com <http://mailplus.yahoo.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.
You can read messages from the OLEDB_DEV archive, unsubscribe from
OLEDB_DEV, or subscribe to other DevelopMentor lists at You can read
messages from the OLEDB_DEV archive, unsubscribe from OLEDB_DEV, or
subscribe to other DevelopMentor lists at 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_01C2B82D.FB6A4500
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=3DGenerator content=3D"Microsoft Word 10 (filtered)">
<title>RE: [OLEDB_DEV] AW: [OLEDB_DEV] OLE DB Consumer =
Templates</title>

<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {margin-right:0in;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.emailstyle18
        {font-family:Arial;
        color:navy;}
span.emailstyle19
        {font-family:Arial;
        color:navy;}
span.EmailStyle20
        {font-family:Arial;
        color:navy;}
span.EmailStyle21
        {font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
</style>

</head>

<body lang=3DEN-US link=3Dblue vlink=3Dblue>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Hi Duncan,</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>I'm getting compilation =
errors.&nbsp;
Where are bClearOnly and pColumnNames coming from?</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>Erik</span></font></p>

<p class=3DMsoNormal><font size=3D2 color=3Dnavy face=3DArial><span =
style=3D'font-size:
10.0pt;font-family:Arial;color:navy'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Duncan Smith
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> =
</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;font-family:Tahoma'>Thursday,
 January 09, 2003</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma'> </span></font><font size=3D2 =
face=3DTahoma><span
 style=3D'font-size:10.0pt;font-family:Tahoma'>2:17 =
PM</span></font><font size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'><br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
[email protected]<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [OLEDB_DEV] =
AW:
[OLEDB_DEV] OLE DB Consumer Templates</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Hi Erik,</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>According to the OLE DB
documentation for the DBBINDING dwMemOwner field: &quot;For bindings in
parameter accessors, consumer-owned memory must always be =
used.&quot;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>I also use the same type =
of accessor
entry (COLUMN_ENTRY_EX_BYREF(n, DBTYPE_STR | DBTYPE_BYREF...)) when =
getting a
rowset containing a column with the XML data. For bindings in row =
accessors, it
gives the client control over when the memory is to be =
freed.</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
  style=3D'font-size:10.0pt;font-family:Arial'>Duncan</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
color=3Dnavy face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Erik Valdes
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> =
</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;font-family:Tahoma'>Thursday,
 January 09, 2003</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma'> </span></font><font size=3D2 =
face=3DTahoma><span
 style=3D'font-size:10.0pt;font-family:Tahoma'>4:05 =
PM</span></font><font size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'><br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
[email protected]<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [OLEDB_DEV] =
AW:
[OLEDB_DEV] OLE DB Consumer Templates</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Hi Duncan,
</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>You've
gone one step further than I expected.&nbsp; I'm not sure I understand =
the
relevance of who owns the memory. &nbsp;However, I had not tried using
DBTYPE_BYREF at all so that is something I need to try.&nbsp; Why is =
the memory
owner important for this issue?</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Thanks,</span></=
font></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>Erik</span></fon=
t></p>

<p class=3DMsoNormal style=3D'margin-left:1.0in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Duncan Smith
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> =
</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;font-family:Tahoma'>Thursday,
 January 09, 2003</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma'> </span></font><font size=3D2 =
face=3DTahoma><span
 style=3D'font-size:10.0pt;font-family:Tahoma'>1:21 =
PM</span></font><font size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'><br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
[email protected]<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [OLEDB_DEV] =
AW:
[OLEDB_DEV] OLE DB Consumer Templates</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>I encountered this exact =
issue. I
wanted to pass a string buffer containing XML data to the provider =
using
client-owned memory. The OLE DB data type I use is DBTYPE_STR | =
DBTYPE_BYREF.
Using the standard OLE DB consumer template macros will result in this =
being
provider-owned memory (see CAccessorBase::Bind in atldbcli.h). So I =
created my
own CAccessorBase type class (called CAccessorBaseEx below) with 2 =
static
methods and created my own bind macro as follows:</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dgreen face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:green'>// This macro is to be used in place of _COLUMN_ENTRY_CODE =
(in
atldbcli.h) for a parameter or</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dgreen face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:green'>// column whose type has the DBTYPE_BYREF bit set.
CAccessorBase::Bind always sets dwMemOwner</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dgreen face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:green'>// to DBMEMOWNER_PROVIDEROWNED if the DBTYPE_BYREF bit =
set. This
macro changes that behavior by</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dgreen face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:green'>// setting dwMemOwner to the value passed as the last =
macro
parameter.</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dgreen face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:green'>// Use COLUMN_ENTRY_EX_BYREF instead of COLUMN_ENTRY_EX =
(in
atldbcli.h) for DBTYPE_BYREF entries.</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dblue face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:blue'>#define</span></font><font size=3D2 face=3D"Courier =
New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>
_COLUMN_ENTRY_CODE_BYREF(nOrdinal, wType, nLength, nPrecision, nScale, =
dataOffset,
lengthOffset, statusOffset, dwMemOwner) \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>if</span></font> (pBuffer =
!=3D NULL) \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{ \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

<font color=3Dblue><span style=3D'color:blue'>if</span></font> =
(!bClearOnly) \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
CAccessorBaseEx::FreeType(wType, pBuffer + dataOffset, dwMemOwner); =
\</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

memset(pBuffer + dataOffset, 0, nLength); \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>else</span></font> <font =
color=3Dblue><span
style=3D'color:blue'>if</span></font> (pBinding !=3D NULL) =
\</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{ \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

ATLASSERT( pColumnNames !=3D NULL ); \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

*pColumnNames =3D NULL; \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

CAccessorBaseEx::Bind(pBinding, nOrdinal, wType, nLength, nPrecision, =
nScale,
eParamIO, \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
dataOffset, lengthOffset, statusOffset, NULL, dwMemOwner); =
\</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

pColumnNames++; \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

pBinding++; \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
} \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nColumns++;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dblue face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:blue'>#define</span></font><font size=3D2 face=3D"Courier =
New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'>
COLUMN_ENTRY_EX_BYREF(nOrdinal, wType, nLength, nPrecision, nScale, =
data,
length, status, dwMemOwner) \</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
_COLUMN_ENTRY_CODE_BYREF(nOrdinal, wType, nLength, nPrecision, nScale,
offsetbuf(data), offsetbuf(length), offsetbuf(status), =
dwMemOwner)</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dblue face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:blue'>class</span></font><font size=3D2 face=3D"Courier =
New"><span
style=3D'font-size:10.0pt;font-family:"Courier New"'> =
CAccessorBaseEx</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>{</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
color=3Dblue face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:blue'>public</span></font><font size=3D2 face=3D"Courier =
New"><span
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>:</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>static</span></font> =
<font
color=3Dblue><span style=3D'color:blue'>void</span></font> =
Bind(DBBINDING*
pBinding, ULONG nOrdinal, DBTYPE wType,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

ULONG nLength, BYTE nPrecision, BYTE nScale, DBPARAMIO =
eParamIO,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

ULONG nDataOffset, ULONG nLengthOffset =3D NULL, ULONG nStatusOffset =
=3D NULL,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

DBOBJECT* pdbobject =3D NULL, DBMEMOWNER dwMemOwner =3D =
DBMEMOWNER_CLIENTOWNED) <font
color=3Dblue><span =
style=3D'color:blue'>throw</span></font>()</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

ATL::CAccessorBase::Bind(</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pBinding,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nOrdinal,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
wType,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nLength,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nPrecision,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nScale,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
eParamIO,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; nDataOffset,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nLengthOffset,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
nStatusOffset,</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
pdbobject);</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

pBinding-&gt;dwMemOwner =3D dwMemOwner;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>static</span></font> =
<font
color=3Dblue><span style=3D'color:blue'>inline</span></font> <font =
color=3Dblue><span
style=3D'color:blue'>void</span></font> FreeType(DBTYPE wType, BYTE* =
pValue,
DBMEMOWNER dwMemOwner) <font color=3Dblue><span =
style=3D'color:blue'>throw</span></font>()</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

<font color=3Dblue><span style=3D'color:blue'>if</span></font> ((wType =
&amp;
DBTYPE_BYREF) &amp;&amp; (dwMemOwner =3D=3D =
DBMEMOWNER_CLIENTOWNED))</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

{</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>void</span></font> * =
pData =3D *(<font
color=3Dblue><span style=3D'color:blue'>void</span></font> =
**)pValue;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>if</span></font> (pData =
!=3D NULL)</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

CoTaskMemFree(pData);</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

}</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=

<font color=3Dblue><span =
style=3D'color:blue'>else</span></font></span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ATL::CAccessorBase::FreeType(wType, pValue);</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>};</span></font>=
</p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Then the accessor I used =
has the following
(the SQL Server data type I am using is text):</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<font color=3Dblue><span style=3D'color:blue'>char</span></font>
*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; m_pszData;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DBLENGTH&nbsp;&nbsp;&nbsp; m_DataLength;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
DBSTATUS&nbsp;&nbsp;&nbsp; m_DataStatus;</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>...</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-indent:.5in;text-autospace:
none'><font size=3D2 face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:
"Courier New"'>COLUMN_ENTRY_EX_BYREF(5, DBTYPE_STR | DBTYPE_BYREF, =
<font
color=3Dblue><span style=3D'color:blue'>sizeof</span></font>(<font =
color=3Dblue><span
style=3D'color:blue'>char</span></font> *), 0, 0, m_pszData, =
m_DataLength, m_DataStatus,
DBMEMOWNER_CLIENTOWNED)</span></font></p>

<p class=3DMsoNormal =
style=3D'margin-left:1.5in;text-autospace:none'><font size=3D2
face=3D"Courier New"><span =
style=3D'font-size:10.0pt;font-family:"Courier =
New"'>&nbsp;</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Hope this =
helps.</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Duncan =
Smith</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:1.5in'><font size=3D2 =
color=3Dnavy
face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial;color:navy'>&nbsp;</span></f=
ont></p>

<p class=3DMsoNormal style=3D'margin-left:2.0in'><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'>-----Original =
Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Erik Valdes
[mailto:[email protected]] <br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> =
</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;font-family:Tahoma'>Thursday,
 January 09, 2003</span></font><font size=3D2 face=3DTahoma><span =
style=3D'font-size:
10.0pt;font-family:Tahoma'> </span></font><font size=3D2 =
face=3DTahoma><span
 style=3D'font-size:10.0pt;font-family:Tahoma'>1:17 =
PM</span></font><font size=3D2
face=3DTahoma><span style=3D'font-size:10.0pt;font-family:Tahoma'><br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
[email protected]<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Re: [OLEDB_DEV] =
AW:
[OLEDB_DEV] OLE DB Consumer Templates</span></font></p>

<p class=3DMsoNormal style=3D'margin-left:2.0in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Hi,</span></font> </p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>I see what you mean about MS recommending =
the storage
object way.&nbsp; I've found a lot of articles describing that.&nbsp; =
However,
I'm having trouble finding anything that gives an example of how to do =
the
in-memory way.&nbsp; Perhaps someone could point me to an example or a =
how-to
document?&nbsp; I'd really appreciate it.&nbsp; </span></font></p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Thanks,</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>Erik</span></font> </p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>-----Original Message-----</span></font> =
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>From: Yuancai Ye [<a
href=3D"mailto:[email protected]">mailto:[email protected]</a>] =
</span></font><br>
<font size=3D2><span style=3D'font-size:10.0pt'>Sent: =
</span></font><font size=3D2><span style=3D'font-size:10.0pt'>Thursday, =
January 09, 2003</span></font><font
size=3D2><span style=3D'font-size:10.0pt'> </span></font><font
 size=3D2><span style=3D'font-size:10.0pt'>9:57 AM</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>To: =
[email protected]</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>Subject: Re: =
[OLEDB_DEV] AW:
[OLEDB_DEV] OLE DB Consumer Templates</span></font> </p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Hi,</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&nbsp;&nbsp;&nbsp; MS =
recommends us
to use storage object for sending</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>a BLOB into a data =
source. However,
as I tested, this</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>way is bad in many =
cases since your
code needs to</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>create a store object =
and database
needs to recover</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>binnary data from the =
store object.
You'd better use</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>in-memory way to send =
BLOB for
faster speed. With use</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>of in-memory way, the =
previous two
extra steps are</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>avoided. Therefore, =
in-memory way
is faster. That is</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>my guess. Test it =
yourself.</span></font>
</p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Regards,</span></font> </p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>Yuancai (Charlie) Ye</span></font> </p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>--- Rudolf Wiener &lt;[email protected]&gt; =
wrote:</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
Erik,</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; For reading and =
writing blobs,
which is what you're</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; in fact using, I =
use the</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; technologies =
recommended and
stream the data with a</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; storage object. =
The</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; macro I use in the =
accessor is</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
BLOB_ENTRY_LENGTH_STATUS. I'm
not sure if</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; this is the best =
way to do it
because I have the</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; impression it =
slows things</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; down a bit. But I =
haven't had
the time yet to look</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; into faster =
alternatives.</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; If you like I can =
send you
excerpts from my app's</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
code.</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
Regards</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; Rudi</span></font> =
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;
-----Urspr&amp;#40689;gliche Nachricht-----</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; Von: =
OLEDB_DEV</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; [<a
href=3D"mailto:[email protected]">mailto:[email protected]=
evelop.com</a>]Im
Auftrag von</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; Erik</span></font> =
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
Valdes</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; =
Gesendet:
Donnerstag, 09. J&amp;#37592;ner 2003 </span></font><font
 size=3D2><span style=3D'font-size:10.0pt'>17:22</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; An:
[email protected]</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; =
Betreff: Re:
[OLEDB_DEV] OLE DB Consumer Templates</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; The =
reason I can't
allocate on the stack is that</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; my variable can be =
any</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; length.&nbsp; It =
essentially
boils down to the string</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; representation of =
an xml</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; file.&nbsp; That =
file can be
any size.&nbsp; When I pass it to</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; my SP, the =
sp's</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; parameter is ntext =
(to allow
for any size).&nbsp;&nbsp; What</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; do people do when =
they</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; want to pass XML =
of unknown
length to a SQL Server</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; stored =
procedure?</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; =
-----Original
Message-----</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; From: =
Peter Moss [<a
href=3D"mailto:[email protected]">mailto:[email protected]</a>]</span></fo=
nt> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; Sent: =
</span></font><font size=3D2><span style=3D'font-size:10.0pt'>Thursday, =
January 09, 2003</span></font><font
size=3D2><span style=3D'font-size:10.0pt'> </span></font><font
 size=3D2><span style=3D'font-size:10.0pt'>7:58 AM</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; To:
[email protected]</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; =
Subject: Re:
[OLEDB_DEV] OLE DB Consumer Templates</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; If I =
remember
right, you can't use the macros for</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
heap-allocated</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; variables.&nbsp; =
If you dig
into the macro definitions, I</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; believe you will =
find</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; that pointers =
offset from the
beginning of 'this'</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; are used.&nbsp; =
Thus, a</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; heap-allocated =
variable like
m_WorkRequest will not</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
work.</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; Why =
can't you just
allocate a TCHAR on the stack</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; frame of the =
object, ie,</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; TCHAR
m_WorkRequest[257];&nbsp;&nbsp;&nbsp;&nbsp; // Or 1 + the =
size</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; of your SP =
parameter size</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; Then =
you can just
use COLUMN_ENTRY.</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; =
HTH,</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp; =
Peter</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; -----Original
Message-----</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; From:
OLEDB_DEV</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; [<a
href=3D"mailto:[email protected]">mailto:[email protected]=
EVELOP.COM</a>]On
Behalf Of</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; Erik</span></font> =
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
Valdes</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; Sent: =
</span></font><font size=3D2><span =
style=3D'font-size:10.0pt'>Wednesday, January 08, =
2003</span></font><font
size=3D2><span style=3D'font-size:10.0pt'> </span></font><font
 size=3D2><span style=3D'font-size:10.0pt'>5:22 PM</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; To:
[email protected]</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;
Subject: [OLEDB_DEV] OLE DB Consumer Templates</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; I'm
having trouble implementing an accessor.</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; I'm trying to use =
a</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; variable =
(m_WorkRequest)
that's dynamically</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; allocated as the =
variable
that's</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; bound to a =
parameter in my accessor
(commented line</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
below).&nbsp;&nbsp; The reason
I</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; need it to be =
dynamic is that
it is XML and can be</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; any length.&nbsp; =
The stored</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; proc's parameter =
is of ntext
type to handle the</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; variable =
length.&nbsp;
However, I</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; don't know at =
compile time how
big to make the</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; buffer for my =
parameter in my</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; accessor.&nbsp; =
What's the
proper way to do this?&nbsp; I've</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; tried =
COLUMN_ENTRY</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; (access =
violation),
COLUMN_ENTRY_LENGTH (different</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; variations =
produce</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; different errors, =
but
basically I can't set the</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
length),</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
COLUMN_ENTRY_TYPE_SIZE
(similar problems as the</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; previous).&nbsp; =
I'm running
out</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; of ideas =
now.&nbsp; The code
below is just one of many,</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; many variations =
I've</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
tried.</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; class
CAddWorkRequest</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;
public:</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
CAddWorkRequest() STD_INIT</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
~CAddWorkRequest()</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
{</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;
if (m_WorkRequest)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
delete [] m_WorkRequest;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
}</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
LONG m_RETURNVALUE;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
LPTSTR m_WorkRequest;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
LONG m_lLength;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
void SetStringParam(LPCTSTR szString,int</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
cBytes)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
{</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;
m_WorkRequest =3D (LPTSTR) new</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
TCHAR[cBytes];</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;
_tcsncpy(m_WorkRequest,szString,cBytes);</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;
m_lLength =3D _tcslen(m_WorkRequest);</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
})</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;
BEGIN_PARAM_MAP(CAddWorkRequest)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
SET_PARAM_TYPE(DBPARAMIO_OUTPUT)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
COLUMN_ENTRY(1, m_RETURNVALUE)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;
SET_PARAM_TYPE(DBPARAMIO_INPUT)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; =
//</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>COLUMN_ENTRY_TYPE_SIZE(2,DBTYPE_STR,_tcslen(m=
_WorkRequest),</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
m_WorkRequest)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp;
END_PARAM_MAP()</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&n=
bsp;
DEFINE_COMMAND(CAddWorkRequest, _T(&quot;{ ? =3D CALL</span></font> =
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; =
dbo.AddWorkRequest;1</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt; (?) =
}&quot;))</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; =
};</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; class =
CAddWorkRequestCommand
: public</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;
CBsDbCommand&lt;CAddWorkRequest&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; =
};</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; foo
(LPTSTR szWor)</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span =
style=3D'font-size:10.0pt'>&gt;&nbsp;&nbsp;&nbsp;&nbsp; {</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>&gt;</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>=3D=3D=3D message =
truncated =3D=3D=3D</span></font>
</p>

<p class=3DMsoNormal style=3D'margin-left:2.0in'><font size=3D3 =
face=3D"Times New Roman"><span
style=3D'font-size:12.0pt'>&nbsp;</span></font></p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>_____________________________________________=
_____</span></font>
<br>
<font size=3D2><span style=3D'font-size:10.0pt'>Do you =
Yahoo!?</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>Yahoo! Mail Plus - =
Powerful.
Affordable. Sign up now.</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'><a =
href=3D"http://mailplus.yahoo.com"
target=3D"_blank">http://mailplus.yahoo.com</a></span></font> </p>

<p style=3D'margin-left:2.0in'><font size=3D2 face=3D"Times New =
Roman"><span
style=3D'font-size:10.0pt'>You can read messages from the OLEDB_DEV =
archive,
unsubscribe from OLEDB_DEV,</span></font> <br>
<font size=3D2><span style=3D'font-size:10.0pt'>or subscribe to other =
DevelopMentor
lists at <a href=3D"http://discuss.develop.com" =
target=3D"_blank">http://discuss.develop.com</a>.</span></font>
</p>

</div>

</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>
You can read messages from the OLEDB_DEV archive, unsubscribe from =
OLEDB_DEV,
or subscribe to other DevelopMentor lists at You can read messages from =
the OLEDB_DEV archive, unsubscribe from OLEDB_DEV,
or subscribe to other DevelopMentor lists at =
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.
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.
------_=_NextPart_001_01C2B82D.FB6A4500--