SqlConnect(h_SqlDbc, "127.0.0.1", SQL_NTS, "USER", SQL_NTS,
"PASSWORD", SQL_NTS);
Shouldn't you need to specify the name of your database (Axxxxx) even
if you only have one defined?
Don't IASPs change the picture somewhat?
MMMmmmmm... Ok, that doesn't answer my question. I can't find any
good documentation that spells out what the 'server' parameter of
SqlConnect() is supposed to be. After some playing around I found
that just using "A10289AF", the name of our database, works, but what
if you're connecting to a database over the net?
Not if the application runs local to the server, and intends to [be]
run in what partition and iASP in which it resides. In that case when
the application is [created or restored to] the server where it will
run, then the application can run connected to the *LOCAL database when
no database is named. If the database name is specified, then that
application created or restored to a different server [LPAR or iASP],
would try to connect to the named server. The value as NULL or empty
string should default to a *LOCAL connect; i.e. similar to an
interactive STRSQL implicit local connection.
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadpexusing.htm
"rtnc=SQLConnect(hdbc,NULL,0,NULL,0,NULL,0);"
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadphdapi.htm
"SQLConnect - Connect to a data source"
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadpfnconn.htm
"SQLConnect() establishes a connection to the target database. The
application can _optionally supply_ _a target SQL database_, an
authorization name, and an authentication string."
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadpfnconn.htm
"If the application does not supply a target database (szDSN), the CLI
uses the _local_ database as the default."
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadprestrictions.htm
"Restrictions ... CLI server mode" "Because DataSources is used to find
the name of the RDB for connection, IBM supports passing a NULL pointer
for the RDB name on SQLConnect to obtain a local connection. This makes
it possible to write a generic program, when there is no prior knowledge
of the system names."
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/cli/rzadpexembeddedsql.htm
"example shows embedded statements in comments and the equivalent DB2®
UDB call level interface (CLI) function calls."
/* EXEC SQL CONNECT TO :server
USER :uid USING :authentication_string; */
SQLAllocEnv (&henv); /* allocate an environment handle */
SQLAllocConnect (henv, &hdbc); /* allocate a connection handle */
/* Connect to database indicated by "server" variable with */
/* authorization-name given in "uid", authentication-string given*/
/* in "pwd". Note server, uid, and pwd contain null-terminated */
/* strings, as indicated by the 3 input lengths set to SQL_NTS */
if (SQLConnect (hdbc, server, SQL_NTS, NULL, SQL_NTS, NULL, SQL_NTS)
!= SQL_SUCCESS)
Regards, Chuck