HP Integrity NonStop H-Series User Manual

Page 58

Advertising
background image

}
else
printf("Connection 2 Successful\n");
st =
SQLConnect(hdbc2,(SQLCHAR*)serverName,SQL_NTS,(SQLCHAR*)UserID,
SQL_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");
odbc_Error(henv,hdbc,SQL_NULL_HSTMT);
}
st = SQLExecDirect(hstmt,(SQLCHAR *)
CreateTable,strlen(CreateTable));
if ( st != SQL_SUCCESS)
{
printf("Error in Create Table: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Create table GGTest Successful\n");
st = SQLExecDirect(hstmt, (SQLCHAR *)
InsertTable,strlen(InsertTable));
if (st != SQL_SUCCESS)
{
printf("Error in Insert Table 1: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Insert Successful: %d\n", value1);
memset(InsertTable, '\0', sizeof(InsertTable));
sprintf(InsertTable, "%s %d %s", "insert into GGTest(c1) values
(", value2, ");");
st = SQLExecDirect(hstmt,(SQLCHAR*)InsertTable,SQL_NTS);
if (st != SQL_SUCCESS)
{
printf("Error in Insert Table 2: GGTest\n");
odbc_Error(henv,hdbc,hstmt);
}
else
printf("Insert Successful: %d\n", value2);
st = SQLRowCount(hstmt,&RowCount);
if (st != SQL_SUCCESS)
{
printf("Error in SQLRowCount()\n");
odbc_Error(henv,hdbc,hstmt);
}

58

Sample ODBC application

Advertising
This manual is related to the following products: