A data source defines all informationen needed by ODBC to connect to a
database. This includes the name of the driver to use (Postgres, mySQL etc.),
the name of the user, his password, the server name on which the database resides
and of course the name of the database. There are a lot more options available.
/etc/odbc.ini is the configuration file for system
data sources. It contains information which will be needed when
connecting to a database. It is modified by a graphical utility
ODBCConfig.
A row is a set of columns in a query. For example in our
table there are two users. Each user makes up a row
in the table or in the result of our query.
This is the input handle in whose context the new handle will be allocated.
If HandleType is SQL_HANDLE_ENV, this is SQL_NULL_HANDLE. For
a handle of type SQL_HANDLE_DBC, this has to be an environment handle, and
if it is SQL_HANDLE_STMT or SQL_HANDLE_DESC, it must be a connection
handle.
OutputHandlePtr
Pointer to a buffer in which to return the allocated handle.
Returns
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE, or SQL_ERROR.
EnvironmentHandle must have been allocated by SQLAllocHandle.
Direction
Which DSN we are looking for. May be on of:
SQL_FETCH_FIRST
Sets up SQLDataSources() to lookup the first of all
available datasources (either user or systemwide).
SQL_FETCH_FIRST_USER
Sets up SQLDataSources() to lookup the first of the
available user datasources.
SQL_FETCH_FIRST_SYSTEM
Sets up SQLDataSources() to lookup the first of the
available system datasources.
SQL_FETCH_NEXT
Fetches the next datasource.
Depending on SQL_FETCH_FIRST_USER, SQL_FETCH_FIRST_SYSTEM
or SQL_FETCH_FIRST this may only be a user datasource,
only a system datasource or one of either.
ServerName
The name of the datasource is returned herein.
BufferLength1
Defines how many chars Servername may contain at most.
NameLength1Ptr
The pointer to the variable in which the actual length of the datasource name
is stored. If NameLength1Ptr is greater than BufferLength1, then
the DSN in ServerName is truncated to fit.
BufferLength
The size of the buffer TargetValuePtr points at in bytes.
Description
The description supplied with the datasource, giving more information on the
datasource in human readable form.
BufferLength2
Defines how many chars Description may contain at most.
NameLength2Ptr
The pointer to the variable in which the actual length of the description
is stored. If NameLength2Ptr is greater than BufferLength2, then
the description in Description is truncated to fit.
Returns
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR, SQL_NO_DATA> or SQL_INVALID_HANDLE.
returns the number of rows affected by INSERT, UPDATE or DELETE.
Many drivers (but not all) return the number of rows returned by the
last executed SELECT statement too.
ConnectionHandle must have been allocated by SQLAllocHandle
and defines the connection which will be modified.
Attribute
which attribute to set
ValuePtr
Pointer to the value for Attribute. Depending on
Attribute, ValuePtr will be a 32-bit integer
value or a pointer to a null-terminated string.
StringLength
If ValuePtr points to a character string or a binary buffer, this
argument should be the length of *ValuePtr.
Otherwise, for ValuePtr of type integer StringLength is ignored.
Returns
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR or SQL_INVALID_HANDLE.
EnvironmentHandle must have been allocated by SQLAllocHandle
Attribute
which attribute to set
ValuePtr
Pointer to the value for Attribute. Depending on
Attribute, ValuePtr will be a 32-bit integer
value or a pointer to a null-terminated string.
StringLength
If ValuePtr points to a character string or a binary buffer, this
argument should be the length of *ValuePtr.
Otherwise, for ValuePtr of type integer StringLength is ignored.
Returns
SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR or SQL_INVALID_HANDLE.