Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Messages - rrijohn

#1
ODBC / ODBC SqlDriverConnect C or other language
August 06, 2024, 01:01:16 PM
looking for information on making connection from executable on linux system where facts resides.

using this connection string works fine with pxpsql
 /usr/pxpodbc/pxpsql -c "Driver=PxPlus;RemotePVKIOHost=192.168.1.5;RemotePVKIOPort=20223;Catalog=FACTS75"

when trying from executable C code
unable to make connection

The driver reported the following error SQLDriverConnect

HY092:1:0:[unixODBC][Driver Manager]Invalid attribute/option identifier

 

code:

 SQLHENV env;

  SQLHDBC dbc;

  SQLHSTMT stmt;

  SQLRETURN ret; /* ODBC API return status */

  SQLCHAR outstr[4096];

  SQLSMALLINT outstrlen;

  SQLCHAR *connStr="Driver=PxPlus;RemotePVKIOHost=192.168.1.5;RemotePVKIOPort=20223;Catalog=FACTS75;";

 

  /* Allocate an environment handle */

  ret=SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);

  CHECK_ERROR(ret, "SQLAllocHandle(SQL_HANDLE_ENV)", env, SQL_HANDLE_ENV);

 

  /* We want ODBC 3 support */

  ret=SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);

  CHECK_ERROR(ret, "SQLSetEnvAttr()", env,  SQL_ATTR_ODBC_VERSION);

 

  /* Allocate a connection handle */

  ret=SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);

  CHECK_ERROR(ret, "SQLAllocHandle()", env,  SQL_HANDLE_DBC);

 

  ret = SQLDriverConnect(dbc, NULL, connStr, SQL_NTS, outstr, sizeof(outstr), &outstrlen, SQL_DRIVER_PROMPT);