TODBCLink
documentation (v0.3b) © by TMS software
Usage - Methods - Properties - Events - Home
To open tables in design
mode:
1) Put the ODBCLINK component on the form
2) Select the TStringGrid or TListView component (or inherited
from TStringGrid or TListView) to which to link
3) Select the driver (depends on installed ODBC drivers on
system)
4) Set the databasefile either to a directory or database file
(to a directory for dBase type databases and to a file for Access
type databases)
5) Select the table
6) Set Active to true
To open tables at runtime :
1) To use OpenDatabase, first set properties Driver, Table
2) Use BrowseDatabase to prompt for driver/database/table
(set doOpen to false to allow setting SQL command after browsing
for table,
otherwise the SQL is the default : SELECT * from TABLE statement)
To save tables at runtime :
1) Set the field names, field types and field sizes for all
columns
2) Set the driver property
3) Set the table property
4) Call the SaveDatabase property
Methods
procedure
OpenDatabase;
Description : Opens the database in the
stringgrid or listview component, specified by DataSource,
DatabaseFile and Table
procedure
SaveDatabase;
Description : Saves the content of the
stringgrid or listview into the database
function
BrowseDatabase(doOpen:boolean):boolean;
Description : Opens the database after selection
from a popup file dialog
function
DataSources:tstrings;
Description : returns a string list of installed
DataSources on the system
function
Drivers:tstrings;
Description : returns a string list of installed
ODBC Drivers on the system
function
Tables:tstrings;
Description : returns a string list of all
tables in the database after DataSource, Databasefile is set
function
HasDataType(sqltype:integer):boolean;
Description : returns true if DataSource
supports this SQL data type
function
CreateDataSource(szDriver,szAttr:string):boolean;
Description : Creates datasource associated with
Driver (not supported in C++Builder 4)
function
InsertRows(RowIndex,RowCount:integer):boolean;
Description : adds rows from the StringGrid or
Listview into the associated database
function
UpdateRows(RowIndex,RowCount:integer):boolean;
Description : updates rows from the StringGrid
or Listview into the associated database
function
DeleteRows(RowIndex,RowCount:integer):boolean;
Description : deletes rows from the database
Properties
property
Active:boolean;
Description : If true, tries to load the
database table into the associated stringgrid or listview
property
SQL:tstringlist;
Description : Can be used to specify a SELECT
statement other than the default SELECT * FROM TABLE.
property
DataSource:string;
Description : selection of the ODBC datasource
as alternative to Driver / Databasefile specification
property
Driver:string;
Description : selection of the ODBC driver to
use as alternative to use of DataSource.
property
Table:string;
Description : selection of table to load from
the database
property
Databasefile:string;
Description : Used with Driver, to load
databasefile with associated Driver.
property
Grid:tStringGrid;
Description : stringgrid in which to load data
from database
property
ListView:tListView;
Description : listview in which to load data
from database
property
Fields:TODBCFieldCollection;
Description : Collection of field descriptions
of all fields in the database. Can be used to select which fields
to load into the Stringgrid of ListView. This collection is used
to specify field names and field types as well when creating a
new database.
property
ShowFields:boolean;
Description : Shows field names in the column
headers if true
property
ShowErrors:boolean;
Description : Shows error dialogs if true
property
UserID:string;
Description : Datasource user ID if required
property
Authentication:string;
Desription : Datasource password if required
Events
property
OnODBCError:TODBCErrorEvent;
Description : event triggered when error occurs
to display error message