Home Dashboard Directory Help
Search

Probems with CRecordset::GetFieldValue(short nIndex, CDBVariant& varValue) in VS2012 by Frekers


Status: 

Closed
 as Fixed Help for as Fixed


1
1
Sign in
to vote
Type: Bug
ID: 768257
Opened: 10/22/2012 6:15:21 AM
Access Restriction: Public
0
Workaround(s)
view
2
User(s) can reproduce this bug

Description

In my own written report i used the function

CRecordset::GetFieldValue(short nIndex,CDBVariant&, varValue)

to get values for various table-fields. In VS2012 i found, that this function do not work
for datafields defined with nvarchar(nn). So i made different tests in VS2010 and VS2012 and
with different databases (ACCESS and SQL-Server 2008R2) to check this function.
I designed one table in ACCESS and the same table in SQL-Server with the following fields:


field 0 nvarChar(25) SQL-Server and Text-Field in ACCESS
field 1 nvarChar(26) SQL-Server and Text-Field in ACCESS
field 2 nvarChar(MAX) SQL-Server and Memo-Field in ACCESS
field 3 smallint     SQL-Server and LongInteger-Field in ACCESS
field 4 smallint     SQL-Server and LongInteger-Field in ACCESS
field 5 smallint     SQL-Server and LongInteger-Field in ACCESS

I wrote the same values in both databases and all fields.

First check: Reading all fields forward

                                 VS2010    VS2012
GetFieldValue(0,var)    okay     Error nRetCode = SQL_NO_DATA_FOUND
GetFieldValue(1,var)    okay     Error nRetCode = SQL_NO_DATA_FOUND
GetFieldValue(2,var)    okay     okay
GetFieldValue(3,var)    okay    okay
GetFieldValue(4,var)    okay    okay
GetFieldValue(5,var)    okay    okay

This test results are independent of the type of database.
Conclusion: GetFieldValue does not work in VS2012 for nvarChar-defined-fields
Remark: Analysing with debugger it seems that computing the length of the field
does not work (attention: in ACCESS and SQL-Server you will get different lengths).
(It is suprising, that in debug mode the buffer of varValue is filled correct!!!!).
In this computing GetFieldValue was called twice (this is changed in VS2012) !!!! This seems not to work (see above).


Second check: Reading the third field(2) with value "M" (only one character in Memo/nvarChar(MAX)).

GetFieldValue(2,var)    Error nRetCode = SQL_NO_DATA_FOUND

This test results are independent of VS2010 and VS2012 and the type of database.
Conclusion: GetFieldValue can't read the field, if it is Memo or nvarChar(MAX) and if there
is only one character (Value "MM" works correct).

Third check: Reading all fields backwards (field-Nr 5. to 2)

                                 ACCESS         SQL-Server
GetFieldValue(5,var)    okay            okay
GetFieldValue(4,var)    okay            Error nRetCode = -1
GetFieldValue(3,var)    okay            Error nRetCode = -1
GetFieldValue(2,var)    okay            Error nRetCode = -1

This test results are independent of VS2010 and VS2012.
Conclusion: GetFieldValue gives different results with different databases.

Fourth check: Reading one field twice

GetFieldValue(5,var)    okay
GetFieldValue(5,var)    Error nRetCode = SQL_NO_DATA_FOUND

This test results are independent of VS2010 and VS2012 and the type of database.
Conclusion: GetFieldValue never can read the same field-number in a record only one time (not twice or more)!!!!!!
Why !!!! See remarks in first check.

Please, check the routine CRecordset::GetFieldValue. Please use different databases, because you will get different results.
I think, if you are working with debugger, you can find the functions, in which the error occurs.
Details
Sign in to post a comment.
Posted by Microsoft on 4/29/2014 at 12:31 PM
Thank you for reporting this issue. This issue has been fixed in Visual Studio 2013. You can install a trial version of Visual Studio 2013 with the fix from: http://go.microsoft.com/?linkid=9832436
Posted by Microsoft on 10/23/2012 at 7:03 PM
Thank you for submitting feedback on Visual Studio and .NET Framework. Your issue has been routed to the appropriate VS development team for investigation. We will contact you if we require any additional information.
Posted by Frekers on 10/23/2012 at 2:40 AM
I have send you an example (TestGetFieldValue.zip). It is demo-project written in VS2010. I tested the programm with VS2010 and VS2012 to see the differences. Also i send two databases (ACCESS and SQL-Server2008R2 folder Database) to check the errors with different databases.
Posted by Microsoft on 10/22/2012 at 11:46 PM
Thanks for your feedback.

In order to fix the issue, we must first reproduce the issue in our labs. In order to efficiently investigate and reproduce this issue, we are requesting additional information outlined below.

Could you please give us a demo project so that we can conduct further research?

Please submit this information to us within 3 business days. We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by Microsoft on 10/22/2012 at 6:50 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
File Name Submitted By Submitted On File Size  
TestGetFieldValue.zip 10/23/2012 91.64 MB