|

the software that grows
with you
| |
|
V32Ado2Dbf()
|
| Returns a .dbf file pulling out info from
an ADODB compliant database based on an SQL statement. |
|
Syntax
|
| V32Sql2Dbf( [cConnect], <cSql>,
<cDbf>, <aStruc>, [lWantInfo], [aProg] ) |
|
Arguments
|
| Param |
Default |
Description |
| cConnect |
|
A valid ADODB compliant database connection
string. |
| cSql |
|
A valid SQL statement recognized by database server in
question on the basis of which information will be returned in the
<cDbf> with structure <aStruc>. |
| cDbf |
|
A valid file name with .dbf extension containg drive,
path and file name with extension. Any extension will do, but better
if it is .dbf.. Note that a new file is created everytime this
function is executed. Vouch32 does not attempt to open an existing
file. |
| aStruc |
|
Two dimensional array of database structure with the
help of which <cDbf> will be created. |
| lWantInfo |
FALSE |
Logical to specify whether Vouch32 should return
number of records returned by the <cSql> or not. Defaults to
FALSE. means control is returned to application immediately after
executing the function. Requested database operations will be
executed at the background. |
| aProg |
NIL |
An optional array with following structure which will
be used to configure the Progress Bar. The structure is:
| cTitle |
Character string to be displayed in
the title bar of progress window. Default is a null string. |
| nBkColor |
RGB color value comprising the
background color of bar area. Default is the value returned by
GetSysColor( COLOR_BTNFACE ). |
| nBarColor |
RGB color value comprising the bar
color. Default is the value returned by GetSysColor(
COLOR_HIGHLITE ). |
| nStyle |
Numeric to control the style of the
Progress Bar one of the two possible values, 1 or 2. Default
is 1 means bar will move as smooth. The other is boxed
progress. |
| lShowPercent |
Logical to switch on or off whether
percent be displayed or not at the middle of progress area.
Default is TRUE. |
| lBorder |
Logical to specify whether a border
be displayed around the progress area or not. Default is
FALSE. |
|
|
|
Returns
|
| NIL or number of records returned if <lWantInfo>
is set to TRUE. |
|
Description
|
| This function supercedes V32Orc2Dbf(),
V32Sql2Dbf() and V32Acs2Dbf(). Programmer is solely responsible for
providing the database server connection string via <cConnect>.
ADODB driver is used to coonect to the database server, so the
connection string must adhere to the ADODB norms.
The point to consider most is the number of fields requested in <cSql>
and number of fields in <aStruc> must match exactly in number and
nature of data being retrieved. If there will be a mismatch, the whole
operation will fail.
|
|
Usage
|
local nRec, cSql, cConnect, cDbf, lWantInfo
local aStruc := {}, aProg := {}
cDbf := 'C:\Vouch32\MySql.dbf'
aadd( aStruc, { 'Name' , 'C', 35, 0 } )
aadd( aStruc, { 'Address', 'C', 35, 0 } )
aadd( aStruc, { 'City' , 'C', 15, 0 } )
aadd( aStruc, { 'Salary' , 'N', 10, 2 } )
aProg := { 'MSSql to Database' }
cDatabase := 'MyDatabase'
cSql := 'SELECT name. address, city, salary FROM employee WHERE salary > 2000'
cConnect := "Provider=SQLOLEDB;Data Source=" + cDatabase
// If records returned info required and a progressbar has to be displayed
//
lWantInfo := .t.
nRec := V32Ado2Dbf( cConnect, cSql, cDbf, aStruc, lWantInfo, aProg )
// If records returned info not required but progressbar has to be displayed
//
lWantInfo := .f.
V32Ado2Dbf( cConnect, cSql, cDbf, aStruc, lWantInfo, aProg )
// In neither info not progressbar needed
//
lWantInfo := .f.
V32Ado2Dbf( cConnect, cSql, cDbf, aStruc, lWantInfo )
|
|
Tips
|
|
|