Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Inserting/selecting BLOB records with Firebird database
Message
De
17/05/2005 13:14:19
Héctor Lizarraga
Gobierno Del Edo de Querétaro
Querétaro, Mexique
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Inserting/selecting BLOB records with Firebird database
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP
Divers
Thread ID:
01014996
Message ID:
01014996
Vues:
71
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform