Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Image in the Database
Message
From
23/09/2003 09:58:35
Metin Emre
Ozcom Bilgisayar Ltd.
Istanbul, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00831330
Message ID:
00831461
Views:
17
General fields a bit difficult to use. Look at this solutions (I got it from a Cetin Basoz's message):
local lcInsertFirst, lcInsertLast
local lcOutFileName, lcTemp, hin, hout
lcInsertFirst = sys(2015)
lcInsertLast = sys(2015)

lnHandle=SQLStringConnect('DRIVER=SQL Server;SERVER=server;DATABASE=Northwind;UID=sa;PWD=*******')

lcTemp = 'T'+sys(2015)
create table (lcTemp) free (FileHolder m nocptrans)
append blank
append memo FileHolder from (getfile())
use
hin=fopen(lcTemp+'.dbf',12)
fseek(hin,43)
fwrite(hin,'G',1)
fclose(hin)
use (lcTemp) alias 'temp'

SQLEXEC(lnHandle, ;
"insert into northwind.dbo.employees "+;
"(LastName,FirstName,Title,Photo)"+;
" values "+;
"('"+lcInsertLast+"','"+lcInsertFirst+"','Sales representative',?temp.FileHolder)")

use in 'temp'
erase (lcTemp+'.*') 

*!* another way:
*!* lcFile=GetFile()
*!* handle=fopen(lcFile)
*!* lnSize=fseek(handle,0,2)
*!* fseek(handle,0,0)
*!* lcContent=fread(handle,lnSize)
*!* fclose(handle)

*!* SQLEXEC(lnHandle, ;
*!* "insert into northwind.dbo.employees "+;
*!* "(LastName,FirstName,Title,Photo)"+;
*!* " values "+;
*!* "('"+lcInsertLast+"','"+lcInsertFirst+"','Sales representative',0x)") && Insert test data

*!* SQLExec(lnHandle,;
*!* [EXEC sp_dboption 'northwind', 'select into/bulkcopy', 'true';]+;
*!* [DECLARE @ptrval binary(16);]+;
*!* [SELECT @ptrval = TEXTPTR(photo) ]+;
*!* [FROM employees ]+;
*!* [WHERE LastName = ']+lcInsertLast+[' and FirstName =']+lcInsertFirst+[';]+;
*!* [UPDATETEXT employees.photo @ptrval 0 NULL ?lcContent ;]+;
*!* [EXEC sp_dboption 'northwind', 'select into/bulkcopy', 'false'])


* READ part
lcOutFileName = "c:\testfile.out" 
SQLEXEC(lnHandle,;
"select * from northwind.dbo.employees "+;
[WHERE LastName = ']+lcInsertLast+[' and FirstName =']+lcInsertFirst+['],;
'mySQLData') && Read from SQL server
SQLDisconnect(lnHandle)
* Extract data from fpt
select mySQLData
lcTemp = 'T'+sys(2015)
copy fields Photo to (lcTemp) next 1
use in 'mySQLData'

Hin = fopen(lcTemp+".fpt")
hout=fcreate(lcOutFileName)
lnSize=fseek(hin,0,2)
fseek(hin,0x204,0) && Move file pointer to offset 0x204 where file size is stored
lnSize = 0
for ix=4 to 1 step -1
     lnSize=lnSize+asc(fread(hin,1))*256^(ix-1)
endfor
fwrite(hout,fread(hin,lnSize),lnSize)
=fclose(hin) and fclose(hout)
erase (lcTemp+'.*')
Previous
Reply
Map
View

Click here to load this message in the networking platform