Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Storing File Contents in SQL Server Image Data Type
Message
De
11/01/2001 10:05:17
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Divers
Thread ID:
00461989
Message ID:
00462196
Vues:
14
Vlad,

How interesting! Thanks for the background. I've never worked with general fields before (beyond using APPEND GENERAL in a few situations). I had no idea that there was no native language way to get the file contents back out of the field. This seems like an amazing omission.

For getting data into SQL Server, I tried the approach of putting the contents into a general field of a cursor and changed my INSERT statement to include ?tablename.fieldname, and that worked just fine. But my application needs to be able to restore the file contents in some circumstances, so it looks like I'll need to resort to your approach. Unfortunate, since it involves alot of extra file IO...sigh.

Thanks again.

-- Randy


>It is VFP problem. When you pass character variable as parameter for SPT query, it used always as character type. Thus this causes truncating it to 255 chras when you try to update memo field and does not allows to update image field. Put data into temporary cursor field and update from tehre.
>
>However, above is only part of the problem. The real problem is that VFP requires general field type to update data for image field on SQL server. There are 2 workarounds. Usually developers use views for that, where you can define for each field how to map types of field. See also Q145991 and Q245714 articles in MSDN.
>
>When you don't want to use views, see following Thread#427023 Message#427217, where I described exact technique of binary file transferring into and from image field on SQL Server (I guess I will put it into the FAQ...).
>
>
>
>>I was trying to write an application that would store a binary image of actual file contents to SQL Server. I stored the file contents to a variable using lcContents = FILETOSTR( ) and then tried to include this in an INSERT command:
>>
>>SQLEXEC( lnConn, [INSERT INTO MyTable ( ,,, Fil_Contents ) VALUES ( ,,, ?lcContents )] )
>>
>>This failed with the following error from SQL Server:
>>
>>Connectivity error: [Microsoft][ODBC SQL Server Driver][SQL Server]Operand type clash: text is incompatible with image
>>
>>Any idea what I did wrong? The field Fil_Contents is using the "image" data type, which BOL indicated was correct for binary data larger than 8K.
>>
>>TIA,
>>
>>-- Randy
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform