tfsrdbc/rdbcTfsAllocDefault.c
#include "sqlrtypes.h"
#include <stdio.h>
{
RDM_TFS tfs;
SQLRETURN ret{};
SQLHENV hEnv;
SQLHDBC hDbc;
char connectStrIn[255];
char connectStrOut[255];
SQLSMALLINT outLen;
/* This creates a default TFS handle */
rc = rdm_rdmAllocTFS (&tfs);
if (rc == sOKAY)
{
rc = rdm_tfsInitialize (tfs);
if (rc == sOKAY)
{
ret = SQL_SUCCESS;
}
else
{
rdm_tfsFree (tfs);
ret = SQL_ERROR;
}
}
{
if (SQL_SUCCEEDED (ret))
{
if (SQL_SUCCEEDED (ret))
{
/* Pass the TFS handle to the ODBC driver */
ret = SQLSetConnectAttr (
if (SQL_SUCCEEDED (ret))
{
/* Connect to the TFS and open the database */
sprintf (connectStrIn, "databases=%s", databaseName);
ret = SQLDriverConnect (
hDbc, NULL, (SQLTCHAR *) connectStrIn, SQL_NTS,
(SQLTCHAR *) connectStrOut, sizeof (connectStrOut),
&outLen, SQL_DRIVER_NOPROMPT);
if (SQL_SUCCEEDED (ret))
{
(void) SQLDisconnect (hDbc);
}
else
{
SQLINTEGER native;
(void) SQLGetDiagRec (
SQL_HANDLE_DBC, hDbc, 1, NULL, &native, NULL, 0,
NULL);
rc = (RDM_RETCODE) native;
}
}
}
(void) SQLFreeHandle (SQL_HANDLE_ENV, hEnv);
}
(void) rdm_tfsFree (tfs);
}
return rc;
}
RDBC_EXPORT SQLRETURN SQLSetConnectAttr(SQLHDBC ConnectionHandle, SQLINTEGER Attribute, SQLPOINTER Value, SQLINTEGER StringLength)
Set an attribute of the SQL API connection.
RDBC_EXPORT SQLRETURN SQLGetDiagRec(SQLSMALLINT HandleType, SQLHANDLE Handle, SQLSMALLINT RecNumber, SQLCHAR *Sqlstate, SQLINTEGER *NativeError, SQLCHAR *MessageText, SQLSMALLINT BufferLength, SQLSMALLINT *TextLength)
Obtain the information about multiple diagnostic record fields.
RDBC_EXPORT SQLRETURN SQLAllocHandle(SQLSMALLINT HandleType, SQLHANDLE InputHandle, SQLHANDLE *OutputHandle)
Allocates an environment, connection, statement, or descriptor handle.
Header for RaimaDB ODBC types.
RDBC_EXPORT SQLRETURN SQLDriverConnect(SQLHDBC ConnectionHandle, SQLHWND WindowHandle, const SQLCHAR *InConnectionString, SQLSMALLINT StringLength1, SQLCHAR *OutConnectionString, SQLSMALLINT BufferLength, SQLSMALLINT *StringLength2Ptr, SQLUSMALLINT DriverCompletion)
Driver Connect.
RDBC_EXPORT SQLRETURN SQLDisconnect(SQLHDBC ConnectionHandle)
Closes the connection associated with a specific connection handle.
RDBC_EXPORT SQLRETURN SQLFreeHandle(SQLSMALLINT HandleType, SQLHANDLE Handle)
Frees resources associated with a specific environment, connection, statement, or descriptor handle.