Microsoft KB Archive/275577

= BUG: Parameter Placeholders with Visual FoxPro (VFP) ODBC Driver and Large Tables =

Article ID: 275577

Article Last Modified on 10/15/2003

-

APPLIES TO


 * Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 3.0
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 4.0
 * Microsoft Open Database Connectivity Driver for Visual FoxPro 5.0

-



This article was previously published under Q275577



SYMPTOMS
If the Visual FoxPro (VFP) ODBC driver is used to write more than 1000 records to a table with more than 64 fields, one of the following errors may occur:
 * Fatal Error: Exception code C0000005 (most common).
 * System locks up or stops responding (hang).
 * Error message: &quot;OLE Exception Error: Exception code C00000005. OLE Object may be corrupt&quot;.
 * Error message (the variable name will vary): &quot;-2147467259 [Microsoft] [ODBC Visual FoxPro Driver] Variable 'Q876P55' is not found&quot;.



CAUSE
This behavior occurs when the table being accessed contains more than 64 columns, and more than 999 records are inserted using parameter placeholders.



RESOLUTION
Avoid the use of parameter placeholders in SQL statements that are passed using SQL Pass Through.

There is presently no resolution for situations that involve remote views of Visual FoxPro tables with more than 64 columns through the Visual FoxPro ODBC driver.

There is currently no resolution for situations that involve ActiveX Data Objects (ADO) recordsets that access Visual FoxPro tables with more than 64 columns through the Visual FoxPro ODBC driver.



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
  Create a program file named &quot;MAKETBLS.PRG&quot; using the following code: * Create folder to contain the main database. MKDIR DATA CREATE DATABASE DATA\maindata DO mk_it WITH 65 CLOSE ALL CREATE DATABASE testdata DO mk_it WITH 65,.T. FOR x = 1 TO 2500 IF MOD(x,500) = 0 WAIT WINDOW &quot;Creating Dummy Recs: &quot;+STR(x) NOWAIT ENDIF APPEND BLANK ENDFOR GO TOP USE
 * Create main database and 1 table with 65 fields.
 * Create database to hold sample data of 2500 records. Also holds the
 * connection to maindata.dbc and 3 views of the tables in maindata.dbc.
 * Populate the source data with 2500 records
 * End of main program.

PROCEDURE mk_it PARAMETER ifcount, ldefault IF PARAMETERS < 2 ldefault = .F.  ENDIF LOCAL i, cstatement, cfcount cfcount= ALLTRIM(STR(ifcount)) * Sample data tables are placed in the root, the destination tables are placed * in the data\ subdir. cstatement=&quot;CREATE TABLE &quot;+IIF(ldefault,&quot;&quot;,&quot;data\&quot;)+&quot;table&quot;+cfcount+ ; &quot;(field_1 i PRIMARY KEY&quot;+IIF(ldefault,&quot; default recno&quot;,&quot;&quot;)+&quot;,&quot;  FOR i = 2 TO ifcount      cfcount= ALLTRIM(STR(i))      cstatement=cstatement+&quot;field_&quot;+cfcount+&quot; c(8)&quot;+IIF(ldefault,&quot; default sys(3)&quot;,&quot;&quot;) + ;         IIF(i=ifcount,&quot;)&quot;,&quot;,&quot;) ENDFOR * Create the table. &cstatement RETURN  Save and then run the program.  Create another program file named &quot;FIELDS65.PRG&quot; using the following code: * TEST ON TABLE WITH 65 DATA ELEMENTS CLOSE ALL CLEAR ALL CLEAR WAIT WINDOW &quot;Cleaning up destination files&quot; NOWAIT SET SAFETY OFF SET EXCLUSIVE ON USE DATA\table65 ZAP CLOSE ALL CLEAR ALL CLEAR
 * Procedure mk_it -
 * Creates a table with the specified number of fields passed in cfcount.
 * If ldefault is .t. then the procedure adds default values to each field of the table.
 * If ldefault is .t. then the procedure adds default values to each field of the table.
 * Make sure that main tables are empty before running this program

gnconnhandle=SQLSTRINGCONN(&quot;DRIVER=Microsoft Visual FoxPro Driver;&quot; + ;  &quot; SourceType=DBC;SourceDB=&quot;+SYS(5)+SYS(2003)+&quot;\data\maindata.dbc&quot;)

? &quot;Inserting data from sample data to &quot;+ALIAS SELE 0 USE table65 GO TOP SCAN WAIT WINDOW &quot;Table65 - Updating &quot;+STR(RECNO)+&quot;. Please wait ...&quot; NOWAIT SCATTER MEMVAR MEMO *   insert into vwtable65 from memvar cmd=&quot;INSERT INTO table65 &quot; + ; &quot;VALUES &quot; + ; &quot;(?m.FIELD_1,&quot; + ;     &quot;?m.FIELD_2,&quot; + ;      &quot;?m.FIELD_3,&quot; + ;      &quot;?m.FIELD_4,&quot; + ;      &quot;?m.FIELD_5,&quot; + ;      &quot;?m.FIELD_6,&quot; + ;      &quot;?m.FIELD_7,&quot; + ;      &quot;?m.FIELD_8,&quot; + ;      &quot;?m.FIELD_9,&quot; + ;      &quot;?m.FIELD_10,&quot; + ;      &quot;?m.FIELD_11,&quot; + ;      &quot;?m.FIELD_12,&quot; + ;      &quot;?m.FIELD_13,&quot; + ;      &quot;?m.FIELD_14,&quot; + ;      &quot;?m.FIELD_15,&quot; + ;      &quot;?m.FIELD_16,&quot; + ;      &quot;?m.FIELD_17,&quot; + ;      &quot;?m.FIELD_18,&quot; + ;      &quot;?m.FIELD_19,&quot; + ;      &quot;?m.FIELD_20,&quot; + ;      &quot;?m.FIELD_21,&quot; + ;      &quot;?m.FIELD_22,&quot; + ;      &quot;?m.FIELD_23,&quot; + ;      &quot;?m.FIELD_24,&quot; + ;      &quot;?m.FIELD_25,&quot; + ;      &quot;?m.FIELD_26,&quot; + ;      &quot;?m.FIELD_27,&quot; + ; &quot;?m.FIELD_28,&quot; + ; &quot;?m.FIELD_29,&quot; + ; &quot;?m.FIELD_30,&quot; + ; &quot;?m.FIELD_31,&quot; + ; &quot;?m.FIELD_32,&quot; + ; &quot;?m.FIELD_33,&quot; + ; &quot;?m.FIELD_34,&quot; + ; &quot;?m.FIELD_35,&quot; + ; &quot;?m.FIELD_36,&quot; + ; &quot;?m.FIELD_37,&quot; + ; &quot;?m.FIELD_38,&quot; + ; &quot;?m.FIELD_39,&quot; + ; &quot;?m.FIELD_40,&quot; + ; &quot;?m.FIELD_41,&quot; + ; &quot;?m.FIELD_42,&quot; + ; &quot;?m.FIELD_43,&quot; + ; &quot;?m.FIELD_44,&quot; + ; &quot;?m.FIELD_45,&quot; + ; &quot;?m.FIELD_46,&quot; + ; &quot;?m.FIELD_47,&quot; + ; &quot;?m.FIELD_48,&quot; + ; &quot;?m.FIELD_49,&quot; + ; &quot;?m.FIELD_50,&quot; + ; &quot;?m.FIELD_51,&quot; + ; &quot;?m.FIELD_52,&quot; + ; &quot;?m.FIELD_53,&quot; + ; &quot;?m.FIELD_54,&quot; + ; &quot;?m.FIELD_55,&quot; + ; &quot;?m.FIELD_56,&quot; + ; &quot;?m.FIELD_57,&quot; + ; &quot;?m.FIELD_58,&quot; + ; &quot;?m.FIELD_59,&quot; + ; &quot;?m.FIELD_60,&quot; + ; &quot;?m.FIELD_61,&quot; + ; &quot;?m.FIELD_62,&quot; + ; &quot;?m.FIELD_63,&quot; + ; &quot;?m.FIELD_64,&quot; + ; &quot;?m.FIELD_65)&quot;

sqlexec(gnconnhandle,cmd)

ENDSCAN

=sqldisconn(gnconnhandle)

IF AERROR(paerror) > 0 ?  ? &quot;Errors Occurred&quot; DISP MEMORY LIKE paerror ELSE ? &quot;Table65 update completed successfully&quot; ENDIF WAIT WINDOW &quot;finished&quot; NOWAIT  Save and then run the program. Note the error that occurs.</li></ol>

<div class="references_section">