Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting/selecting BLOB records with Firebird database
Message
From
17/05/2005 13:14:19
Héctor Lizarraga
Gobierno Del Edo de Querétaro
Querétaro, Mexico
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Inserting/selecting BLOB records with Firebird database
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP
Miscellaneous
Thread ID:
01014996
Message ID:
01014996
Views:
70
Does anyone knows how can I insert/select BLOB records into a Firebird database?

Here are the steps:

I assure that the result cursor be of vfp BLOB type
=CURSORSETPROP("MapBinary",.T.,0)

First, I connect to the database:

lcDriver = "{Firebird/InterBase(r) driver}"
lcUid = "SYSDBA"
lcPwd = "masterkey"
lcFbd = "127.0.0.1:Prueba"
lcDsnString = [DRIVER=] + lcDriver + [;UID=] + lcUid + [;PWD=] + lcPwd + [;DBNAME=] + lcFbd

nHnd=SQLSTRINGCONNECT(lcDsnString)

*///
Second, I populate a string containing the jpg file I want to upload to the database. This is in a prg called blob.prg

cChar = ''
nFileHnd=FOPEN('c:\esc.jpg') && This file is 8k long
=FSEEK(nFileHnd, 0, 0)
DO WHILE !FEOF(nFileHnd)
cChar = cChar + FREAD(nFileHnd,1)
ENDDO

*///
Then I send the sql string to the server

cQuery = 'insert into TEST_TABLE (TEST_FIELD) VALUES (?cChar)'
SQLPREPARE(nHnd,cQuery,'curResult')
SQLEXEC(nHnd)

*///
The record seems to be OK in the IB Expert admin tool.

cQuery = 'SELECT * FROM TEST_TABLE'
SQLPREPARE(nHnd,cQuery,'curResult')
SQLEXEC(nHnd)

*///
=STRTOFILE(curResult.test_field,'C:\esc2.jpg')

The result file is 4k long and is not recognized as a jpg. There are no ODBC errors.

What is wrong?
Any ideas?

Thanks in advance
Héctor L.
Mexico
Next
Reply
Map
View

Click here to load this message in the networking platform