C++, OLEDB, running a query that returns 2 columns: an int and a varchar(50).
So I want to put it in
struct OutputData
{
int intID;
wchar_t* lpszName;
} outputData;
So, I bind
m_oleDBUtils.CreateDBBindings(true, &pRowsetBindings[0], 1,
offsetof(OutputData, intID), 4, DBTYPE_I4, 0,
DBPARAMIO_NOTPARAM);
m_oleDBUtils.CreateDBBindings(false, &pRowsetBindings[1], 2,
offsetof(OutputData, lpszName), 50, DBTYPE_WSTR | DBTYPE_BYREF, 0,
DBPARAMIO_NOTPARAM);
Etc. etc.
I build for Win32. Under Windows 7 x64 (running the 32-bit DLL!), it works. Under Windows XP x86, I get consistent garbage in the first two characters (with the rest of the string being fine). So instead of
One
Two
Three
I see
XXe
XXo
XXree
Again, the garbage val开发者_Go百科ue is the same for all records. I thought it was alignment, but /Zp2, /Zp4, /Zp8 and /Zp16 all show the same behavior.
Any thoughts?
Switch to client-owned memory and /Zp1 fixed it.
精彩评论