This is kind of a \'double\' question that might have a single answer.
I\'m working with an Odbc Connection with an AS/400, with my connection string as follows:
If anyone runs into this post and is using the IBM.Data.DB2.iSeries .NET data provider as I am, the key point taken from above was using the naming=1
and not specifying a "Default Collection". I was finally successful when using the following portion in my connection string
LibraryList= MyLibrary1,MyLibrary2,MyLibrary3,MyLibrary4;naming=1;
You can qualify your table names as library.filename and not have to deal with any library list issues.
For more information:
Client Access ODBC: Default Libraries Setting
ODBC connection string keywords
Excerpts of the relevant parts are:
With SQL naming convention, the operating system does not perform a library list search to locate an unqualified object. If a default collection is defined, the default collection is used to resolve unqualified SQL statements.
...
With the SYS naming convention, the unqualified SQL statements go to the default collection. If there is no default collection, the current library is used. If no current library is specified, the library list is used.
...
Default Collection
A job attribute set by ODBC that determines the library used when processing SQL statements that contain unqualified SQL names. When a default collection is set all unqualified objects except procedures, functions and types must reside in the default collection, regardless of naming convention.
...
How can I get ODBC to search the library list?
As explained above, edit the ODBC data source and set system naming to SYS. The default library must be empty, or on versions older than R510, the default libraries setting must start with a comma so that no default collection is defined (for example, ",MYLIB1, MYLIB2").
Try this connection string to enable system naming and to not set a default library:
driver={iSeries Access ODBC Driver}; system={0}; uid={1}; pwd={2}; naming=1; DefaultLibraries=,*USRLIBL,LibraryB;
An alternative is to set up a separate user profile for each environment. Since the *USRLIBL is set by the job description, this would entail setting up a separate job description as well. For example:
user: WEB job desc: WEB library list: CUSTPROD, ITEMPROD, UTILITY
user: WEBTEST job desc: WEBTEST library list: CUSTTEST, ITEMTEST, UTILITY
The C# code does not change except for using the test or production user ID to authenticate.