Open System Services ODBC/MX Client Driver Manual for SQL/MX Release 3.2.1 (H06.26+, J06.15+)
st = SQLAllocConnect(henv, &hdbc1);
if (hdbc1 == NULL)
{
printf("Error in allocating connection Handle 2!\n");
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLAllocConnect(henv, &hdbc2);
if (hdbc2 == NULL)
{
printf("Error in allocating connection Handle 3!\n");
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st =
SQLConnect(hdbc,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,SQ
L_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 1\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
exit(1);
}
else
printf("Connection 1 Successful\n");
st = SQLSetConnectAttr(hdbc,
SQL_ATTR_TXN_ISOLATION,(SQLPOINTER)8,0);
if (st != SQL_SUCCESS)
{
printf("Error in SQLSetConnectAttr()\n");
odbc_Error(henv,hdbc,hstmt);
}
st =
SQLConnect(hdbc1,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,S
QL_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 2\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
}
else
printf("Connection 2 Successful\n");
st =
SQLConnect(hdbc2,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,S
QL_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 3\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
}
else
printf("Connection 3 Successful\n");
st = SQLGetInfo(hdbc,SQL_DBMS_NAME, infoValueBuf,
sizeof(infoValueBuf), &StringLengthPtr);
infoValuePtr = infoValueBuf;
if (st != SQL_SUCCESS)
{
printf("Error in SQLGetInfo\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("\n\tDBMS NAME : %s\n\n", infoValuePtr);
printf("\n\tUsing Connection 1\n\n");
st = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHDBC)hdbc, &hstmt);
if (hstmt == NULL)
{
printf("Error in allocating Statement Handle\n");
Execution and Testing of Sample ODBC Application 57










