#include "fivewin.ch"
#include "adodef.ch" // important
//----------------------------------------------------------------------------//
function Main()
local oCn, cTableName, aJpg
oCn := <......... Ado connection object. Connect in your own way ..>
cTableName := "MyImages" // any other name you like
aJpg := { array of jpg files wih path }
AdoImportImages( oCn, "MyImages", aJpg )
oCn:Close()
return nil
//----------------------------------------------------------------------------//
function AdoImportImages( oCn, cTable, aJpg )
CreateTable( oCn, cTable )
UsingSQL( oCn, cTable, cFileNoPath( aJpg[ 1 ] ), MemoRead( aJpg[ 1 ] ) )
UsingAdoRecordSet( oCn, cTable, cFileNoPath( aJpg[ 2 ] ), MemoRead( aJpg[ 2 ] ) )
UsingTDataRow( oCn, cTable, cFileNoPath( aJpg[ 3 ] ), MemoRead( aJpg[ 3 ] ) )
BrowseImagesTable( oCn, cTable )
return nil
//----------------------------------------------------------------------------//
function CreateTable( oCn, cTable )
TRY
oCn:Execute( "DROP TABLE " + cTable )
CATCH
END
FWAdoCreateTable( cTable, { ;
{ "IMAGENAME", 'C', 20, 0 }, ;
{ "IMAGEDATA", 'm', 10, 0 } }, oCn )
/*
Notes: Use this function to create tables. Thie same syntax and notiation are compatible with different databases.
Data Type small 'm' indicates binary data in contast to "M" meaning text memo.
*/
return nil
//----------------------------------------------------------------------------//
function UsingSQL( oCn, cTable, cImageName, cImageData )
local cSql
PRIVATE table_name := cTable
cSql := SQL INSERT INTO &table_name ( IMAGENAME,IMAGEDATA ) VALUES ( cImageName, cImageData )
oCn:Execute( cSql )
// This works for ADO and non ado connections
return nil
//----------------------------------------------------------------------------//
function UsingAdoRecordSet( oCn, cTable, cImageName, cImageData )
local oRs
oRs := FW_OpenRecordSet( oCn, cTable )
oRs:AddNew( { "ImageName", "ImageData" }, { cImageName, STRTOHEX( cImagedata ) } )
oRs:Close()
return nil
//----------------------------------------------------------------------------//
function UsingTDataRow( oCn, cTable, cImageName, cImageData )
local oRs, oRec
oRs := FW_OpenRecordSet( oCn, cTable )
oRec := TDataRow():New( oRs, .t. )
oRec:ImageName := cImageName
oRec:ImageData := cImageData
oRec:Save()
oRs:Close()
return nil
//----------------------------------------------------------------------------//
function BrowseImagesTable( oCn, cTable )
local oRs := FW_OpenRecordSet( oCn, cTable )
XBROWSER oRs FASTEDIT SETUP ( oBrw:ImageData:nDataBmpAlign := AL_CENTER, oBrw:lCanPaste := .t. )
oRs:Close()
return nil
oSQL:execute( "INSERT INTO 'boeken' ( nummer,cover) VALUES ( 1,"+STRTOHEX(memoread("C:\COVERS\1.jpg"))+" )")
oBrw:bline = {|| { str(oRs:Fields( 'nummer' ):Value),oRs:Fields( 'cover' ):Value }}
nageswaragunupudi wrote:It is xbrowse which is provided with display of images.
I advise you to use xbrowse for this purpose
I have use
Code:
oSQL:execute( "INSERT INTO 'boeken' ( nummer,cover) VALUES ( 1,"+STRTOHEX(memoread("C:\COVERS\1.jpg"))+" )")
to inport the jpg-files into the database.
cSql := SQL INSERT INTO boeken ( nummer, cover ) VALUES ( 1, memoread( "c:\covers\1.jpg" ) )
oCn:Execute( cSql )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 68 guests