Microsoft KB Archive/145991

= How To Inserting an OLE Object into a SQL Table by Using SPT =

Article ID: 145991

Article Last Modified on 7/1/2004

-

APPLIES TO


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

-



This article was previously published under Q145991



SUMMARY
This article explains how to place OLE information into a SQL table by using the SQL Pass Through (SPT) function SQLEXEC. To achieve this, you need to pass the field as a parameter instead of passing a file name value.



MORE INFORMATION
To place an OLE object such as a .wav or an .avi file into an Image field in a SQL table, you need to store it in a Visual FoxPro general field, and then call INSERT INTO to insert the general field in an Image field. For example, you can use the following syntax if you have a connection to a data source and you want to store the OLE information to an image field named imagfld: = SQLEXEC(mhandle,"INSERT INTO test(field1,imagfld);      VALUES('Sound',?table.g_fld)") In this example, the field name of the local table is passed as a parameter to the server. This ensures that Visual FoxPro preserves the binary format of the OLE object.

Note that if you pass the .wav file name in the INSERT command and bring the information back to Visual FoxPro, the error "OLE Object is invalid" is displayed when you click the General field. If you have an OLE object that is not stored in a .dbf file, you can create a temporary cursor and store the file in a cursor before you upload it. For example: CREATE CURSOR tmpole (g_fld G)  APPEND BLANK APPEND GENERAL g_fld FROM "C:\win95\media\chimes.wav"

Keywords: kbcode KB145991

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.