Microsoft KB Archive/262067

= BUG: RStoCursor in Vfpcom.dll File Does Not Work with Certain Data Types =

Article ID: 262067

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a
 * Microsoft Visual FoxPro 6.0 Professional Edition

-



This article was previously published under Q262067



SYMPTOMS
Microsoft Visual FoxPro developers often make use of the VFPCOM Utility, which is available for download from the Microsoft Visual FoxPro Web site. Among other things, this sample allows users to convert an ADO recordset into a FoxPro cursor through its RSToCursor method.

When you attempt to create a cursor from an ADO recordset by using the RSToCursor method, the numeric, float, and Double data types are not converted properly. This behavior results in a -10 return code from the object, and the FoxPro cursor is not created.

Additional information on the Vfpcom sample and its error codes may be found in the &quot;References&quot; section later in this article.



RESOLUTION
There is a Microsoft Visual FoxPro RS2DBF function inside of the program named RS2DBF.PRG that converts an ADO recordset to a Visual FoxPro cursor and retains numeric, float, and Double data types.

More information and a download point can be found at this Microsoft Web site:

RS2DBF.EXE



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 If you have not done so already, download and unzip the VFPCOM Utility from the Microsoft Visual FoxPro samples Web site. Follow the instructions in the &quot;Installation and Setup&quot; section of the Vfpcom.htm file that accompanies the sample.  Copy the following code to a new program, and then run it to demonstrate the problem. Note that there is a return value from the Vfpcom.dll of -10 (&quot;Failed to create Fox cursor&quot;). This occurs when the utility tries to convert an ADO Recordset with one float, numeric or double field, into a Fox cursor. ******************************* START CODE ******************************* CLEA LOCAL loVFPCOM, loRS, lnError

loVFPCOM = CREATEOBJECT(&quot;vfpcom.comutil&quot;) IF VARTYPE(loVFPCOM) # 'O' OR ISNULL(loVFPCOM) MESSAGEBOX(&quot;Problem creating VFPCOM Object. Exiting&quot;) RETURN .F. ENDIF

MAKE_CURSOR('NUMERIC') ? &quot;*** NUMERIC FIELD TEST ***&quot; loRS = CREATEOBJECT(&quot;adodb.recordset&quot;) lnError = loVFPCOM.CURSORTORS(loRS) ? &quot;CursorToRs Err Code for table with 1 NUMERIC field... &quot;, TRANSFORM(lnError) lnError = loVFPCOM.RSTOCURSOR(loRS, &quot;test&quot;) ? &quot;RStoCURSOR Err Code for table with 1 NUMERIC field... &quot;, TRANSFORM(lnError) ? loRS = NULL RELEASE loRS
 * ~ Let's try with a cursor with one, NUMERIC field

MAKE_CURSOR('FLOAT') ? &quot;*** FLOAT FIELD TEST ***&quot; loRS = CREATEOBJECT(&quot;adodb.recordset&quot;) lnError = loVFPCOM.CURSORTORS(loRS) ? &quot;CursorToRs Err Code for table with 1 FLOAT field... &quot;, TRANSFORM(lnError) lnError = loVFPCOM.RSTOCURSOR(loRS, &quot;test&quot;) ? &quot;RStoCURSOR Err Code for table with 1 FLOAT field... &quot;, TRANSFORM(lnError) ? loRS = NULL RELEASE loRS
 * ~ Let's try with a cursor with one, FLOAT field

MAKE_CURSOR('DOUBLE') ? &quot;*** DOUBLE FIELD TEST ***&quot; loRS = CREATEOBJECT(&quot;adodb.recordset&quot;) lnError = loVFPCOM.CURSORTORS(loRS) ? &quot;CursorToRs Err Code for table with 1 DOUBLE field... &quot;, TRANSFORM(lnError) lnError = loVFPCOM.RSTOCURSOR(loRS, &quot;test&quot;) ? &quot;RStoCURSOR Err Code for table with 1 DOUBLE field... &quot;, TRANSFORM(lnError) ? loRS = NULL RELEASE loRS
 * ~ Let's try with a cursor with one, DOUBLE field

loRS = NULL loVFPCOM = NULL RELEASE loRS, loVFPCOM
 * ~ Clean-up


 * ~ PROCEDURES ~

PROCEDURE MAKE_CURSOR(lcFldType) DO CASE CASE lcFldType = 'NUMERIC' CREATE CURSOR test(n_num N(5))

CASE lcFldType = 'FLOAT' CREATE CURSOR test(floatfld F(10))

CASE lcFldType = 'DOUBLE' CREATE CURSOR test(dobfld B(2)) ENDCASE

LOCAL i   FOR i = 1 TO 10 INSERT INTO test VALUES(i) NEXT i                   
 * END CODE *******************************

