I am having a problem with the ATL Consumer Template classes when I
attempt to retrieve string data from the database.
Here it is...
I create the table and set one column to a length of 2, then fill it with
data. All of this i done with scripts.(SQL Server or Oracle)
Next, I attempt to bind a string variable and call CCommand::Open. Even
though I specifiy a max width of 2 when binding, I only get one character
back. if I give it a max length of 10, then I only get 9 back, etc...
I have played around with it and have found that the templates seem to only
retrieve X - 1 characters, instead of X. Anyone see this before? Maybe it
assumes a "end-of-string" marker as that last char? I have looked through
the MSDN support site, but can't seem to find any mention of this type of
bug.
-Matt
Bob Beauchemin
bo...@develop.com
Matt <mh...@one.net> wrote in message news:OvoF9XQY$GA.202@cppssbbsa05...
the buffer that I bind is allocated by new char[MaxLength + 1] for that
reason.
However, it looks like the providers just assume that you have not done
that. They always return MaxLength - 1 characters.
-Matt
Bob Beauchemin
bo...@develop.com
Matt <mh...@one.net> wrote in message
news:#tudfOUY$GA....@cppssbbsa02.microsoft.com...
and I allocate length+1 for binding.
The length that I get from CColumns is the correct max length. And if I bind
length+1 as the MaxLength in AddBindEntry(), then it works fine with no
other changes.
it seems to me that the problem is the with the ATL classes assuming that
the bound MaxLength is the real MaxLength + 1. So they truncate the data.
-matt
cmd.GetColumnInfo(&ulColumns, &pColumnInfo, &pStrings);
// lines omitted
cmd.AddBindEntry(0, DBTYPE_STR, pColumnInfo->ulColumnSize +1.....)
The fact that atldbcli.h refers to the 3rd parameter of AddBindEntry as
"column size" is misleading, as it just feeds that value into the accessor
as maxLength.
Bob Beauchemin
bo...@develop.com
Matt <mh...@one.net> wrote in message news:eJvsVJeY$GA.260@cppssbbsa04...
CColumns is a class that allows access to column info. I found it in the
MDSN help. As for the column length, I understand what you are saying now.
Now I understand why I was having problems.
Thanks for the info!
-Matt