Dot Net Fluke: Getting by on C# for iSeries RPG Developers

Useful tutorials on C# and .NET for RPG iSeries AS/400 developers. Brought to you from the folks at AranRock Consulting

9/22/08

Connection String Stinger - Phantom Library List

.Net can look for your tables in a library the same name as your user id  even if you supply a library list. This can cause your SQL 'selects' to fail.

Take a look:
Here's a basic connection string using the IBM supplied iDB2 Classes:

DataSource=192.168.0.1; UserID=colm;Password=xxxx;LibraryList= CusLib,ARlib, QGPL

At first glance everything looks good, right?

So now I want to get at my table MYCUST in CusLib. Should be a no brainer. However if I run the SQL command 'Select * from MYCUST' guess what I get?  - A big fat error like this:

SQL0204 - File MYCSUT in COLM not found

What??. CusLib is on the TOP - I don't even mention library Colm.  What's going on?

IBM says that if you are using the SQL naming convention that it sets the default collection or library to the library with the same name as the user id. I have no idea why they do this! Anyway if you have this issue the simple fix is to specify the default collection. i.e. defaultcollection=cuslib

Here's the new connection string

DataSource=192.168.0.1; UserID=colm;Password=xxxx;LibraryList= CusLib,ARlib, QGPL;DefaultCollection=CUSLIB

Labels: , , ,

9/12/08

How to run your .net batch programs without showing a dos screen

If you are writing a 'batch' .NET program, that is a program that does not have user interaction- a Console program you may not want the console (the DOS screen) to pop up at all - especially if it is running frequently as a scheduled task in windows.

There are a couple of ways to prevent the DOS screen flashing up every time your program runs. Here's a simple way:

 

  1. Create a batch file (Myapp.bat for example) to run your app.
  2. Create a shortcut (.lnk) to Myapp.bat
  3. Right click on the shortcut and select Properties
  4. Change the drop down for Run from Normal to Minimized
  5. Now run your shortcut. The dos screen should not appear and the program should appear on your taskbar as it runs.
  6. If it doesn't work for some reason try entering the Target name manually rather than using what was entered when you created it. Sounds nuts but people have found this as a solution when the shortcut still shows the dos promptimage

Labels: , , ,