Howdy,
I'm having an issue with using CRecordset::GetFieldValue to access a
column of floats in a SQL Server database. i'm using Visual Studio .net
2003.
The problem is the strings that are being returned are all 1 character
too long.
For example GetFieldValue returns the cstring "93.99999999999999",
which is 17 chars long, but if i call GetLength on the cstring it says
its 18 characters long.
When i stepped through CRecordset::GetFieldValueEx to see what was
going on, i noticed that getfieldvalueex, while setting the string
value, calls CString::GetBufferSetLength but has no corresponding
CString::releasebuffer.
So i've changed my code to something like this
CString sVal;
while (!rs.IsEOF())
{
rs.GetFieldValue((short) 0, sVal);
sVal.ReleaseBuffer();
saLookups.Add(sVal);
}
and now all my strings are the right length.
So am i doing something fundamentally wrong in how i'm getting the
values from the database? or is this what i'm supposed to do?