Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Storing Word documents in SQL Server
Message
 
 
To
06/11/2004 13:47:03
Jon Neale
Bond International Software
Wootton Bassett, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 6 SP5
Miscellaneous
Thread ID:
00958440
Message ID:
00959414
Views:
8
Jon,

This code works fine for me either with SPT or remove views:
public gnSQLConnection
gnSQLConnection = 0

gnSQLConnection = SQLSTRINGCONNECT( "driver={SQL Server};server=(local);database=test;trusted_connection=yes;" )

lcFile = filetostr( "C:\Program Files\VSNET\CompactFrameworkSDK\v1.0.5000\Windows CE\sqlce20sql2ksp2.exe" )

? sqlexec( gnSQLConnection, "insert into SQLFileStore values ( 'sqlce20sql2ksp2.exe', ?lcFile )" )

? sqlexec( gnSQLConnection, "select * from SQLFileStore", "sptcursor" )
? sptcursor.tFileContent == lcFile

? strtofile( sptCursor.tFileContent, "c:\temp\sqlce20sql2ksp2.exe" )
the file in his case 13mb in size.
* I have a dbc with a connection and updateable remote view setup to the SQL database

use vwSQLFileStore in 0

? vwSQLFileStore.tFileContent == sptcursor.tFileContent
? vwSQLFileStore.tFileContent == lcFile

select vwSQLFileStore
append blank
replace cFileName with "copied.exe", ;
        tFileContent with lcFile

? tableupdate( .t., .t., "vwSQLFileStore" )

use
use vwSQLFileStore in 0
select vwSQLFileStore
locate for cFileName = "copied.exe"
? vwSQLFileStore.tFileContent == lcFile
The database test had this table in it:
create table SQLFileStore ( cFilename char(60), tFileContent text )
In all cases the == test succeeds.

>We read the word documetn into memvar by using this:
>
> w_retval = ""
> w_fh = FOPEN(p_fn, 0)
> IF w_fh >= 0
> w_flen = FSEEK(w_fh, 0,2)
> =FSEEK(w_fh, 0,0)
> w_retval = FREAD(w_fh, w_flen)
> =FCLOSE(w_fh)
> ENDIF
>
>We then save this back to a memo field in the Foxpro View of the SQL Table.
>
>Then when we try and reopen the document it errors. I have read somewhere that binary information passed back to SQL from Foxpro was changed. In that SQL modified some of the characters passed back from Foxpro. My understanding is that the Image type doesnt do this just the text type.
>
>I think I need to some more reading and maybe just try it out and see what happens.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform