Microsoft KB Archive/107596: Difference between revisions
(importing KB archive) |
m (Text replacement - "&" to "&") |
||
(3 intermediate revisions by the same user not shown) | |||
Line 34: | Line 34: | ||
* Generates a GP fault in FoxPro for Windows 2.5, 2.5a, 2.5b | * 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 | * Crashes or Locks FoxPro for MS-DOS 2.5, 2.5a, 2.5b | ||
* Build a 200 (Windows) or 150 (MS-DOS) column table & | * Build a 200 (Windows) or 150 (MS-DOS) column table & execute DBCols() | ||
* | * | ||
* Assumes: FPSQL.FLL (Windows) or FPSQL.PLB (MS-DOS) Loaded | * Assumes: FPSQL.FLL (Windows) or FPSQL.PLB (MS-DOS) Loaded | ||
* : A valid connection handle to SQL Server | * : A valid connection handle to SQL Server | ||
* : In | * : In "pubs" database | ||
* | * | ||
* Example: From the command window enter the following: | * Example: From the command window enter the following: | ||
* : SET LIBRARY TO FPSQL.FLL (PLB) | * : SET LIBRARY TO FPSQL.FLL (PLB) | ||
* : mhandle = dbconnect( | * : mhandle = dbconnect("<DataSource>","<user>","<password>","") | ||
* : mresult = dbexec(mhandle, | * : mresult = dbexec(mhandle,"use pubs") | ||
* : DO sqltb WITH | * : DO sqltb WITH "<tabletocreate>" | ||
************************************************************************ | ************************************************************************ | ||
PARAMETERS p_table | PARAMETERS p_table | ||
IF PARAMETERS()=0 | IF PARAMETERS()=0 | ||
WAIT WINDOW | WAIT WINDOW "You must pass a table name to this procedure.." | ||
RETURN | RETURN | ||
ENDIF | ENDIF | ||
Line 61: | Line 61: | ||
STORE SPACE(10) TO msqlc,msqle | STORE SPACE(10) TO msqlc,msqle | ||
STORE 0 TO mresult | STORE 0 TO mresult | ||
IF TYPE( | IF TYPE("mhandle") = "U" | ||
STORE 1 TO mhandle | STORE 1 TO mhandle | ||
ENDIF | ENDIF | ||
mtable = | mtable = "dbo."+p_table | ||
* Build SQL CREATE TABLE command string | * Build SQL CREATE TABLE command string | ||
msqlc = | msqlc = "create table &mtable (" | ||
WAIT WINDOW | WAIT WINDOW "Command string:"+msqlc+" will be created" TIMEOUT 2 | ||
WAIT WINDOW NOWAIT | WAIT WINDOW NOWAIT "Creating SQL command string.." | ||
FOR i = 1 TO IIF(_WINDOWS,200,150) | FOR i = 1 TO IIF(_WINDOWS,200,150) | ||
mvar = | mvar = "C" + ukey(9)+" char(10)," | ||
msqlc = msqlc + mvar | msqlc = msqlc + mvar | ||
ENDFOR | ENDFOR | ||
msqlc = LEFT(msqlc, LEN(msqlc)-1)+ | msqlc = LEFT(msqlc, LEN(msqlc)-1)+")" | ||
WAIT WINDOW NOWAIT | WAIT WINDOW NOWAIT "Create table string built.." | ||
mresult = dbexec(mhandle,msqlc) | mresult = dbexec(mhandle,msqlc) | ||
IF mresult = 1 | IF mresult = 1 | ||
WAIT WINDOW | WAIT WINDOW "Table created.." TIMEOUT 2 | ||
ELSE | ELSE | ||
WAIT WINDOW | WAIT WINDOW "Error - table not created.." timeout 5 | ||
? alltrim(sqe()) | ? alltrim(sqe()) | ||
ENDIF | ENDIF | ||
IF mresult = 1 | IF mresult = 1 | ||
WAIT WINDOW | WAIT WINDOW "Attempt dbcols() on new table.." TIMEOUT 2 | ||
mresult = dbcols(mhandle,mtable) | mresult = dbcols(mhandle,mtable) | ||
? mresult | ? mresult | ||
ELSE | ELSE | ||
WAIT WINDOW | WAIT WINDOW "Please clear error condition and rerun" TIMEOUT 5 | ||
ENDIF | ENDIF | ||
SET TALK ON | SET TALK ON | ||
FUNCTION ukey | FUNCTION ukey | ||
* Return unique key of length | * Return unique key of length <lenkey> | ||
PARAMETER lenkey | PARAMETER lenkey | ||
IF PARAMETERS()=0 | IF PARAMETERS()=0 | ||
Line 116: | Line 116: | ||
PRIVATE num,msg,mresult | PRIVATE num,msg,mresult | ||
STORE 0 TO num,mresult | STORE 0 TO num,mresult | ||
STORE | STORE "" TO msg | ||
mresult = dberror(1,@msg,@num) | mresult = dberror(1,@msg,@num) | ||
RETURN msg+ | RETURN msg+"/"+ALLTRIM(STR(num,6,0)) | ||
* EOF sqe | * EOF sqe | ||
Latest revision as of 12:25, 21 July 2020
FIX: DBCols() with Large Number of Columns Causes GPFID: Q107596 2.5x 2.6x | 2.5x 2.6x WINDOWS | MS-DOS kbprg kbfixlist kbbuglist The information in this article applies to:
SYMPTOMSWhen 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. STATUSMicrosoft 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 INFORMATIONSteps to Reproduce ProblemCAUTION: 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 REFERENCESFor 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 |