How To Inserting an OLE Object into a SQL Table by Using SPT (145991)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 3.0b
  • Microsoft Visual FoxPro for Windows 6.0

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"
				

Modification Type:MinorLast Reviewed:7/1/2004
Keywords:kbcode KB145991