Microsoft KB Archive/107596

From BetaArchive Wiki

FIX: DBCols() with Large Number of Columns Causes GPF

ID: Q107596

2.5x 2.6x | 2.5x 2.6x

WINDOWS   | MS-DOS

kbprg kbfixlist kbbuglist The information in this article applies to:

  • Microsoft FoxPro for Windows, versions 2.5x, 2.6x
  • Microsoft FoxPro for MS-DOS, versions 2.5x, 2.6x

SYMPTOMS

When you are using FoxPro with the Connectivity Kit (CK), executing a DBCols() statement on a SQL Server table with approximately 200 columns in FoxPro for Windows or 150 columns in FoxPro for MS-DOS will cause a general protection (GP) fault in FoxPro for Windows and will cause FoxPro for MS- DOS to hang or crash.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. This problem was corrected in Visual FoxPro 3.0 for Windows.

MORE INFORMATION

Steps to Reproduce Problem

CAUTION: Save your work and close all other programs before following these steps. This procedure may result in lost data and/or corrupted files.

To reproduce the problem, you must have the CK and SQL Server installed. Follow the steps at the top of the following program, and then run the program.

   ************************************************************************
   * SQLTB.PRG
   * Generates a GP fault in FoxPro for Windows 2.5, 2.5a, 2.5b
   * Crashes or Locks FoxPro for MS-DOS 2.5, 2.5a, 2.5b
   * Build a 200 (Windows) or 150 (MS-DOS) column table & execute DBCols()
   *
   * Assumes: FPSQL.FLL (Windows) or FPSQL.PLB (MS-DOS) Loaded
   *        : A valid connection handle to SQL Server
   *        : In "pubs" database
   *
   * Example: From the command window enter the following:
   *        : SET LIBRARY TO FPSQL.FLL (PLB)
   *        : mhandle = dbconnect("<DataSource>","<user>","<password>","")
   *        : mresult = dbexec(mhandle,"use pubs")
   *        : DO sqltb WITH "<tabletocreate>"
   ************************************************************************
   PARAMETERS p_table
   IF PARAMETERS()=0
      WAIT WINDOW "You must pass a table name to this procedure.."
      RETURN
   ENDIF

   SET TALK OFF

   * Initialize variables
   PUBLIC msqlc
   PUBLIC msqle
   PUBLIC mresult
   PUBLIC mtable
   STORE SPACE(10) TO msqlc,msqle
   STORE 0 TO mresult
   IF TYPE("mhandle") = "U"
      STORE 1 TO mhandle
   ENDIF
   mtable = "dbo."+p_table

   * Build SQL CREATE TABLE command string
   msqlc = "create table &mtable ("
   WAIT WINDOW "Command string:"+msqlc+" will be created" TIMEOUT 2
   WAIT WINDOW NOWAIT "Creating SQL command string.."

   FOR i = 1 TO IIF(_WINDOWS,200,150)
      mvar = "C" + ukey(9)+" char(10),"
      msqlc = msqlc + mvar
   ENDFOR
   msqlc = LEFT(msqlc, LEN(msqlc)-1)+")"
   WAIT WINDOW NOWAIT "Create table string built.."

   mresult = dbexec(mhandle,msqlc)
   IF mresult = 1
      WAIT WINDOW "Table created.." TIMEOUT 2
   ELSE
      WAIT WINDOW "Error - table not created.." timeout 5
      ? alltrim(sqe())
   ENDIF

   IF mresult = 1
      WAIT WINDOW "Attempt dbcols() on new table.." TIMEOUT 2
      mresult = dbcols(mhandle,mtable)
      ? mresult
   ELSE
      WAIT WINDOW "Please clear error condition and rerun" TIMEOUT 5
   ENDIF
   SET TALK ON

   FUNCTION ukey
      * Return unique key of length <lenkey>
      PARAMETER lenkey
      IF PARAMETERS()=0
         lenkey=8
      ENDIF
      IF lenkey=1
         RETURN RIGHT(SYS(3),1)
      ENDIF
      len1=FLOOR(lenkey/2)
      len2=lenkey-len1
      key1= RIGHT(SYS(3),len1)
      key2= RIGHT(SYS(2015),len2)

      RETURN key1+key2
      * EOF ukey

   FUNCTION sqe
      * Evaluate and display ODBC Error
      PRIVATE num,msg,mresult
      STORE 0 TO num,mresult
      STORE "" TO msg
      mresult = dberror(1,@msg,@num)

      RETURN msg+"/"+ALLTRIM(STR(num,6,0))
      * EOF sqe

      ** EOP sqltb

REFERENCES

For more information on the Ukey function, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q106708
   TITLE     : How to Generate Unique Key Field Values

Additional reference words: FoxDos FoxWin VFoxWin 2.50 2.50a 2.50b 2.60 2.60a gpf fixlist 3.00 buglist2.50 buglist2.50a buglist2.50b buglist2.60 buglist2.60a lock up freeze halt stop responding KBCategory: kbprg kbfixlist kbbuglist KBSubcategory: FxtoolCk

Keywords          : FxtoolCk kbbuglist kbfixlist
Version           : 2.5x 2.6x | 2.5x 2.6x
Platform          : MS-DOS WINDOWS
Solution Type     : kbfix

Last Reviewed: November 25, 1998
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.