Click or drag to resize

DbServer.BLOBDirectImport Method (Long, FileSpec)

X#
Import a file into a BLOB file and return a pointer to the data.

Namespace:  XSharp.VO.SDK
Assembly:  XSharp.VORDDClasses (in XSharp.VORDDClasses.dll) Version: 2.19
Syntax
 VIRTUAL METHOD BLOBDirectImport(
	nPointer AS LONG,
	oFSSource AS FileSpec
) AS USUAL
Request Example View Source

Parameters

nPointer
Type: Long
A pointer to the BLOB data which will be released after the import. This pointer can be obtained using DBServer:BLOBDirectPut(), DBServer:BLOBDirectImport(), or DBServer:FieldInfo(DBS_BLOB_POINTER, nFieldPos). Passing 0 disables the release of data.
Important! If specified, DBServer:BLOBDirectImport() releases the space associated with nOldPointer for reuse by other data. Therefore, it is illegal to use nOldPointer with any of the BLOB methods after passing it as an argument to this method. Use the method's return value to refer to the newly stored data.
oFSSource
Type: FileSpec
A string or filespec object that specifies the name of the file from which to read the BLOB data, including an optional drive, directory, and extension. See SetDefault() and SetPath() for file searching and creation rules. No default extension is assumed.

Return Value

Type: Usual
A numeric pointer to the BLOB image stored in the source file.
Remarks
This method attempts to openthe source file in shared mode. If the file does not exist, a runtime error is raised. If the file is successfully opened, the operation proceeds. If access is denied because, for example, another process has exclusive use of the file, NetErr() is set to TRUE and the data server's Status property is set. Refer to the 'Concurrency Control' chapter in the Programmer's Guide for more information on resolving concurrency conflicts.
Tip Tip
There are no restrictions on the size of the source file except that you must have enough disk space to make the copy.
DBServer:BLOBDirectImport() provides a mechanism for copying the contents of a file into a BLOB file. DBServer:BLOBDirectImport() is used in conjunction with DBServer:BLOBDirectExport() to transfer data back and forth between external files and BLOB files. You can use DBServer:BLOBDirectImport() with a variety of file types, including graphics images, word processor files, and printer fonts. These two methods are excellent for creating databases of documents, graphics, sounds, and so on.
Important! After importing a file with DBServer:BLOBDirectImport(), nNewPointer, the return value, is the only way to access the data from the BLOB file. It is up to you, the developer, to provide permanent storage for this reference (see example below)
Tip Tip
DBServer:FieldInfo(DBS_BLOB_TYPE, nFieldPos) will return "C" (string) for any memo field created using DBServer:BLOBDirectImport().
Examples
This example illustrates storing setup information in a BLOB file, then selectively retrieving the stored information:
X#
 1FUNCTION PutSettings(aColors AS ARRAY,;
 2aPaths AS ARRAY, aPW AS ARRAY) AS VOID
 3LOCAL aSettings AS ARRAY
 4LOCAL oDBSetup AS DBServer
 5oDBSetup := Setup{}
 6aSettings := {}
 7AAdd(aSettings, oDBSetup:BLOBDirectPut(0, aColors))
 8AAdd(aSettings, oDBSetup:BLOBDirectPut(0, aPaths))
 9AAdd(aSettings, oDBSetup:BLOBDirectPut(0, aPW))
10oDBSetup:BLOBRootPut(aSettings)
11oDBSetup:Close()
12FUNCTION GetColors() AS ARRAY
13LOCAL aSettings AS ARRAY
14LOCAL aColors  AS ARRAY
15LOCAL oDBSetup AS DBServer
16oDBSetup := Setup{}
17aSettings := oDBSetup:BLOBRootGet()
18aColors := oDBSetup:BLOBDirectGet(aSettings[1])
19oDBSetup:Close()
20RETURN aColors
See Also