PxPlus User Forum

Main Board => Discussions => ODBC => Topic started by: rrijohn on August 06, 2024, 01:01:16 PM

Title: ODBC SqlDriverConnect C or other language
Post by: rrijohn on 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);
Title: Re: ODBC SqlDriverConnect C or other language
Post by: Devon Austen on August 06, 2024, 01:16:30 PM
Try

ret = SQLDriverConnect(dbc, NULL, connStr, SQL_NTS, NULL, 0, &outstrlen, SQL_DRIVER_NOPROMPT);

The main difference is NOPROMPT instead of PROMPT and passing null for outStr.