EasyTable ODBC Driver: Tutorial
This tutorial illustrates how to connect to a data source, fetch data from existing table,
create a new table and insert values into it,
retrieve those values, drop this table, and disconnect from the data source.
In so doing, it acquaints you with most of ODBC functions.
To connect to a data source:
Manual: Using the ODBC Administrator, create an EasyTable user data source called EasyTable_Test. Specify the database path to test.edb in Demo\Test folder. For information about creating data sources with the ODBC Administrator, see "Managing Data Sources" under "ODBC Data Source Administrator" in the Microsoft Data Access Components (MDAC) SDK.
From your application: Call ConfigDSN with lpszDriver="EasyTable"
Call the following functions:
SQLAllocEnv
SQLAllocConnect
SQLDriverConnect with parameters "DSN=EasyTable_Test;"
or
SQLDriverConnect with parameters "DATABASE=test.edb;"
or
SQLConnect with parameter ServerName set to "EasyTable_Test;"
To fetch data from existing table:
Call SQLAllocStmt
Call SQLExecDirect with statement "SELECT str25 FROM Table1"
Until SQLFetch returns 100 (SQL_NO_DATA) instead of 0 (SQL_SUCCESS)
call SQLFetch to scroll to new record then SQLGetData to fetch the data.
Call SQLFreeStmt with option 0 (SQL_CLOSE).
To create a table and insert values into it:
Call SQLExecDirect with statement "CREATE TABLE NewTable (City CHAR(10), State CHAR(2))"
Call SQLExecDirect with statement "INSERT INTO NewTable VALUES ('Phoenix', 'CA')"
Call SQLExecDirect with statement "INSERT INTO NewTable VALUES ('Cheyenne', 'WY')"
To retrieve data from a table:
Call SQLExecDirect with statement "SELECT * FROM NewTable"
Call SQLNumResultCol . It should returns 2
While SQLFetch returns 0 (SQL_SUCCESS) until SQLFetch returns 100 (SQL_NO_DATA)
call SQLFetch to scroll to new record then call SQLGetData twice as it is defined by
SQLNumResultCol to fetch the data from the first and the second columns.
Call SQLFreeStmt with option 0 (SQL_CLOSE).
To drop a table:
Call SQLExecDirect with statement "Drop table NewTable"
To disconnect from a data source:
Call SQLFreeStmt with option 1 (SQL_DROP)
Call SQLDisconnect
Call SQLFreeConnect
Call SQLFreeEnv
Custom Development!
Custom Development for you -
Delphi and
C++ Builder !
Experts in Database, Networking, Data Compression and Encryption.
10+ years experience.
Contact Us!
讠믬/a>
讠믬