Microsoft KB Archive/169154
Article ID: 169154
Article Last Modified on 12/11/1999
- 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 Q169154
When upsizing FoxPro data to an SQL server, empty general field records may cause an error when browsing the resulting SQL table.
This is caused by an empty general field being upsized as an hex 20 (which is a space character). FoxPro expects to see binary data in the general field rather than an ASCII character.
The problem can be avoided by setting the General field to accept NULL values. This can be done in either of two methods when creating the table: programmatically or visually.
To programmatically allow a NULL value, use the NULL keyword when creating the field in the table.
* The following line of code creates a table called 'gendata'. The * General field in the table, 'gfield' accepts NULL values. CREATE TABLE gendata (gfield G NULL)
To set the field to accept NULL values using the visual interface, place a check mark in the NULL column for the field, in the Table Designer dialog box.
Microsoft is researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
Steps to Reproduce Behavior
There are three parts in setting up this example: Part 1 is to create a small table with empty general records to be used in the Upsize Wizard. Part 2 is to upsize the data to an SQL server. Part 3 is to create a remote view of the SQL data to observe the error.
Part 1 - Create a table with empty general field records:
Save the following code to a file called Creatabl.prg:
*** Begin code *** CLOSE ALL CREATE DATABASE test CREATE TABLE gendata (gfield G) APPEND BLANK APPEND BLANK APPEND BLANK GO 1 APPEND GENERAL gfield FROM c:\windows\waves.bmp GO 3 APPEND GENERAL gfield FROM c:\windows\tiles.bmp *** End code ***
Part 2 - Upsize the data to an SQL server:
- From the Visual FoxPro Tools menu, select Wizards and click Upsizing.
- In the Wizard Selection dialog box, click SQL Server Upsizing Wizard and click OK.
- In Step 1, select the Test database, and click Next.
- In Step 2, select the SQL data source to upsize to, and click the Next. NOTE: At this point, a login screen may come up. Login into the SQL data source to continue.
- In Step 3, move the Gendata table to the Selected Tables pane, and click Next.
- In Step 4, select Map Field Data Types, and click Next to continue.
- In Step 5, select the target database to upsize the data to (this could be an existing or new database). Then, click Next. NOTE: If an existing database is chosen, Steps 5 and Steps 6 will be bypassed. Otherwise, if this is a new database, the following steps will be performed.
- In Step 6, set the appropriate database properties, and click Next.
- In Step 7, set the appropriate log properties, and click OK.
- In Step 8, set the upsizing options. In this test, all of the check boxes can be cleared. Then, click Next.
- In Step 9, click Finish to upsize the data to the SQL server.
Part 3 - Create a remote view of the upsized-SQL data:
Open the Test database if it's not already open by entering the following command in the Visual FoxPro Command window:
OPEN DATABASE test
- From the Visual FoxPro File menu, select New and click Remote View. Click Wizard to bring up the Remote View Wizard.
- In Step 1, select the data source where the upsized data exists, and click Next. NOTE: At this point, a login screen may come up. Login into the SQL data source to continue.
- In Step 2, move "gfield" from the "gendata" table to the Selected Fields pane, and click Finish to bypass Steps 3, 4, and 5, which are not necessary in this example.
- In Step 6, select "Save remote view and browse", and click Finish. NOTE: Once the Remote View Browse window appears, open "gfield" for record 2 and observe the "OLE Object is Invalid or Corrupt" error message.
Keywords: kberrmsg kbprb kbcode KB169154