HP Integrity NonStop H-Series User Manual
Page 57

scanf("%s", Password);
strcpy(CreateTable,"create table GGTest(c1 int)");
sprintf(InsertTable, "%s %d %s", "insert into GGTest(c1) values
(", value1, ");");
strcpy(SelectTable,"select * from GGTest" );
printf("\n\tUsing Data Source : %s \n\n", serverName);
if (!strncmp(serverName, "TDM_Default_DataSource",
strlen(serverName)))
defaultDS = true;
st = SQLAllocEnv(&henv);
if (henv == NULL)
{
printf("Error in allocating Env Handle!\n");
odbc_Error(SQL_NULL_HENV,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(void*)SQL_OV_ODBC3, 0);
if (st != SQL_SUCCESS)
{
printf("Error in SQLSetEnvAttr :: %d\n", st);
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
st = SQLAllocConnect(henv, &hdbc);
if (hdbc == NULL)
{
printf("Error in allocating connection Handle 1!\n");
odbc_Error(henv,SQL_NULL_HDBC,SQL_NULL_HSTMT);
}
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,
SQL_NTS,(SQLCHAR*)Password,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Connection 2\n");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
Testing the sample
57