Click here to Skip to main content
15,896,348 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am facing some problem with CDBVariant. I am using CDBVariant variable (varValue) in my code to fetch some strings(of MEMO type) from a mdb file, using GetFieldValue(). When the application is built in "Release" mode in VS2008, the value returned by 'varValue' is truncated i.e. the last character of the string is truncated. If I build the same application in"Debug" mode, its returning the complete string without any problem.
Below mentioned is my code snippet:


C#
/*Get all the language Strings from the Database.. */
        strReadSqlAllLangString ="SELECT * FROM StringsTable";
        nRetVal = rs_lang_all.Open ( CRecordset::forwardOnly, \
                    strReadSqlAllLangString, CRecordset::readOnly );

        // Create a CDBVariant object to
        // store field data
        CDBVariant varValue;

        nFields = rs_lang_all.GetODBCFieldCount( );
        short nFieldType = DEFAULT_FIELD_TYPE;
        int nTmp;
        while ( !rs_lang_all.IsEOF() )
        {
            for(nIndex = 0; nIndex < nFields; nIndex++ )
            {
                /* Get the current field value and put it in strString1 */
                rs_lang_all.GetFieldValue(nIndex, varValue);

                // Check for Null/Bad pointer. If found, then replace the string to ""
                if (varValue.m_dwType == 0)
                {
                    strString3 = "";
                }
                else
                {
                    strString3 = *varValue.m_pstring;
                    nTmp = strString3.GetLength();
                }

                arr_strAllLangStrings[nIndex][nLangStr] = strString3;
            }
            /*Move to the next nSet of strings in all 28 languages*/
            rs_lang_all.MoveNext();
            nLangStr++;
        }


I tried adding nFieldType = DEFAULT_FIELD_TYPE, but that also didnt work out. I dont know what is different in Debug mode & Release mode. In Debug mode-Its working & in Release mode- its not.

Please help me in fixing this. If anyone wants more info on this problem Or the entire code to refer, please let me know.

Thanks. Any kind of Help will be appreciated.

Best regards,
Dinesh
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900