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-6
Execution and Testing of Sample ODBC Application
if(argc>1)
{
if(!strcmp(argv[1], "-help"))
{
printf("USAGE: odbcdemo <DataSourceName>\n");
printf("Eg: odbcdemo DEMO\n");
printf("Note: Default Data Source will be used in case no DS
specified!\n");
return 0;
}
serverName = argv[1];
}
printf("User Name: ");
scanf("%s", UserID);
printf("Password : ");
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);
Example A-3. Sample ODBC Application Code










