Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Storing Images in SQL - Again
Message
General information
Forum:
Visual FoxPro
Category:
Pictures and Image processing
Miscellaneous
Thread ID:
01247561
Message ID:
01247568
Views:
24
I see the square with the 'X' ibn it.
The image is a .PNG.

I created this PRG to load the images into a SQL table. The SQL table has an Image column holding
the image. The ImageFile is mapped to Blob in the DBC.
CLOSE DATABASES ALL
MODIFY DATABASE ImageLoad.DBC NOWAIT

IF USED("v_GenImages")
	USE IN v_GenImages
ENDIF

SELECT 0
USE v_GenImages
DELETE FROM v_GenImages

SET STEP ON 

nTotImages = ADIR(aImages, "Images\*.png")

FOR nImage = 1 TO nTotImages

	cImageName = LOWER(aImages[nImage, 1])
	cImageCode = LOWER(GETWORDNUM(cImageName, 1, "_"))
	cImageFile = LOWER(SYS(5) + SYS(2003) + "\Images\" + aImages[nImage, 1])

	INSERT INTO v_GenImages;
		(imagesize, imagecode, imagename);
		VALUES;
		(16, cImageCode, cImageName)

	APPEND MEMO ImageFile FROM (cImageFile) OVERWRITE

	
ENDFOR

RETURN
Next I use the following to get the images back out. The STRTOFILE() creates the file ok and
I can see it.
nHandle = SQLSTRINGCONNECT(cConnString)

IF nHandle > -1

	CURSORSETPROP("MapBinary", .T., 0)

	nResult = SQLEXEC(nHandle, "select * from genimages", "Images")
	
	IF nResult > -1

		SELECT Images
		SCAN
	
			cFileName = cDestDir + ALLTRIM(Images.ImageName)

			=STRTOFILE(ImageFile , cFileName)
		
			DO FORM Test
		
		ENDSCAN
		
	ELSE
		? "Error"
	ENDIF
	
	SQLDISCONNECT(nHandle)

ELSE
	? "Not connected"
ENDIF
The form's init has
ThisForm.image1.PictureVal = Images.ImageFile
Yes when the form finishes Initing, I don't see the image.







>>What do you see? Does it work if you put original image in a blob field? Can you view image if you >>save it to a file? What kind of imigae is it?
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform