Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Storing Image to SQL VarBinary Problem
Message
 
To
20/07/2007 17:28:38
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01242501
Message ID:
01242509
Views:
39
cMyImage = 'C:\mypath\myjpg.jpg'
lcfile2 = FILETOSTR(cMyImage)
CREATE CURSOR crsTest (Fld1 M NOCPTRANS)
INSERT INTO crsTest VALUES (lcfile2)
TEXT TO lcSQL NOSHOW PRETEXT 15 TEXTMERGE
    INSERT INTO MySQLTable (MyKeyField, MyStatus, MyLastName, MyImage)
                    VALUES (5,'A','Jones',CONVERT(varbinary(max),?crsTest.Fld1))
ENDTEXT
IF sqlexec(6,lcSql) < 0 && Hmmm 6? HA
   AERROR(laError)
   MessageBox(laError[1,2])
ENDIF
This also works:
cMyImage = GETFILE()
lcfile2 = FILETOSTR(cMyImage)
TEXT TO lcSQL NOSHOW PRETEXT 15 TEXTMERGE
    INSERT INTO TestMe (MyTest)
                    VALUES (CONVERT(varbinary(max),<<0hlcfile2>>))
ENDTEXT
IF sqlexec(6,lcSql) < 0 && Hmmm 6? HA
   AERROR(laError)
   MessageBox(laError[1,2])
ENDIF
But I am not sure what you will get back :-)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform