Windows API Reference
Database Services
ODBC (Open Database Connectivity)
ODBC is a standard application programming interface for accessing database management systems (DBMS). It allows applications to access data in different database systems without rewriting the code for each database.
Core Functions
-
SQLAllocEnv
Allocates an environment handle.
-
SQLConnect
Establishes a connection to a data source.
-
SQLExecDirect
Executes an SQL statement directly.
-
SQLFetch
Fetches the next row of a result set.
-
SQLDisconnect
Disassociates from a data source.
-
SQLFreeEnv
Frees an environment handle.
Key Structures
SQLHANDLE
: Handle to environment, connection, statement, or descriptor.SQLSMALLINT
,SQLINTEGER
,SQLUINTEGER
, etc.: Data types used in ODBC functions.
SQLAllocEnv
RETCODE SQLAllocEnv(HENV *Phenv)
Allocates an environment handle and returns a pointer to the handle.
SQL_SUCCESS, SQL_ERROR, SQL_INVALID_HANDLE.
An application must call SQLAllocEnv
before calling any other ODBC function except SQLAllocHandle
.
SQLConnect
RETCODE SQLConnect(HDBC hDbc, SQLCHAR *szDSN, SQLSMALLINT cbDSN, SQLCHAR *szUID, SQLSMALLINT cbUID, SQLCHAR *szAuthStr, SQLSMALLINT cbAuthStr)
Establishes a connection to a data source using a Data Source Name (DSN).
szDSN
in bytes.
szUID
in bytes.
szAuthStr
in bytes.
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, SQL_INVALID_HANDLE, SQL_NEED_DATA.
SQLExecDirect
RETCODE SQLExecDirect(HSTMT hStmt, SQLCHAR *szSqlStr, SQLINTEGER cbSqlStr)
Executes an SQL statement directly without needing to prepare it first.
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, SQL_INVALID_HANDLE, SQL_NO_DATA, SQL_STILL_EXECUTING.
SQLFetch
RETCODE SQLFetch(HSTMT hStmt)
Fetches the next row of a result set into the application's bound columns.
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, SQL_INVALID_HANDLE, SQL_NO_DATA, SQL_STILL_EXECUTING.
SQLDisconnect
RETCODE SQLDisconnect(HDBC hDbc)
Disassociates an application from a data source.
SQL_SUCCESS, SQL_ERROR, SQL_INVALID_HANDLE.
SQLFreeEnv
RETCODE SQLFreeEnv(HENV hEnv)
Frees an environment handle and releases all associated resources.
SQL_SUCCESS, SQL_ERROR, SQL_INVALID_HANDLE.
OLE DB
OLE DB (Object Linking and Embedding Database) is a Microsoft data access technology for providing a consistent interface to a variety of information sources, including relational databases and spreadsheets.
Core Components
- Providers: Implement OLE DB interfaces to expose data.
- Consumers: Applications that use OLE DB providers to access data.
- Rowsets: A collection of rows returned by a query.
- Commands: Objects that execute SQL or other query languages.
Key Interfaces
IDBInitialize
ISessionProperties
IOpenRowset
ICommandText
IRowset
Extensible Storage Engine (ESE)
The Extensible Storage Engine (ESE), also known as Jet Blue, is an indexed, transactional database application programming interface (API) that provides high-performance access to data.
Common Uses
- Windows Search Indexing
- Exchange Server Mailboxes
- Active Directory
Key Functions
JetCreateInstance
JetInit2
JetBeginTransaction
JetCommitTransaction
JetOpenDatabase
JetCloseDatabase