Open System Services ODBC/MX Client Driver (SQL/MX 2.x)
Sample ODBC Application
HP NonStop Open System Services ODBC/MX Client Driver—544990-002
A-8
Execution and Testing of Sample ODBC Application
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");
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 tabel 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 Succesfull: %d\n", value1);
Example A-3. Sample ODBC Application Code










