<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-5752867610009374467</atom:id><lastBuildDate>Mon, 06 Jul 2009 19:17:08 +0000</lastBuildDate><title>Dot Net Fluke:  Getting by on C# for iSeries RPG Developers</title><description>Useful tutorials on C# and .NET for RPG iSeries AS/400 developers. Brought to you from the folks at AranRock Consulting</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/</link><managingEditor>noreply@blogger.com (Colm P O Byrne)</managingEditor><generator>Blogger</generator><openSearch:totalResults>35</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><geo:lat>33.992411</geo:lat><geo:long>-118.465313</geo:long><creativeCommons:license>http://creativecommons.org/licenses/by/2.0/</creativeCommons:license><image><link>http://creativecommons.org/licenses/by/2.0/</link><url>http://creativecommons.org/images/public/somerights20.gif</url><title>Some Rights Reserved</title></image><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/DotNetFlukeZoo" type="application/rss+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">DotNetFlukeZoo</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2FDotNetFlukeZoo" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FDotNetFlukeZoo" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2FDotNetFlukeZoo" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.bloglines.com/sub/http://feeds.feedburner.com/DotNetFlukeZoo" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2FDotNetFlukeZoo" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2FDotNetFlukeZoo" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2FDotNetFlukeZoo" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-8709761881843009381</guid><pubDate>Tue, 02 Jun 2009 19:09:00 +0000</pubDate><atom:updated>2009-06-23T14:09:58.411-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">stored procedures</category><category domain="http://www.blogger.com/atom/ns#">SQL</category><title>How to Create Stored Procedures</title><description>&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Stored procedures are programs written in SQL.  They are their own object, stored on the iSeries db and can accept parameters. They are programs with their own variables, flow control and can be called by any other application. Their benefit is in being able to stack a bunch of statements together and so improve performance, reduce network traffic and make your life simple! Why have multiple db statements executing when you can issue one that does it all! It encourages separation of the data from logic and forces you to be modular. Begone Spaghetti!&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;They also help security; especially useful in distributed  apps (client/server)  so that the code that updates the db is hidden in the stored procedure and not visible at the front end. Finally they are a super simple way to do a remote call.&lt;/span&gt;&lt;/span&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;You create a stored procedure using iSeries Navigator or directly through your 5250 screen. I'll go over the 5250 way since it is more verbose than the GUI.&lt;br /&gt;To create our procedure we will use  the &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;CREATE PROCEDURE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; command in SQL -called an SQL stored procedure. You can also create them in RPG - an external procedure. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;There are 4 main parts to the creation:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;1. The NAME of the procedure&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="  -webkit-border-horizontal-spacing: 20px; -webkit-border-vertical-spacing: 20px; "&gt;&lt;pre class="code"  style=" ;font-size:9pt;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; CREATE PROCEDURE &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;MyProcedureName&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"  style=" ;font-size:9pt;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;2. Parameters&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; I have an input parm of 10 chars and an I/O parm of type integer&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"  style=" ;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style="white-space: normal; "&gt;&lt;pre class="code"  style=" ;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;( IN REQKEY CHARACTER(10), INOUT RETVAL INTEGER )&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"   style="  ;font-family:monospace;font-size:9pt;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-weight: normal;"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;3. Procedure properties&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" font-weight: normal; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;The language will always be SQL&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"   style="  ;font-family:monospace;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style=" white-space: normal; "&gt;&lt;pre class="code"   style="  ;font-family:monospace;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; LANGUAGE SQL &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" white-space: normal; "&gt;&lt;pre class="code"   style="  ;font-family:monospace;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=" font-weight: bold; "&gt;&lt;span class="Apple-style-span" style="font-weight: normal; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;3. The procedure code&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code"   style="  ;font-family:monospace;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style=" "&gt;&lt;span class="Apple-style-span" style="  white-space: normal; "&gt;&lt;pre class="code"   style="  ;font-family:monospace;font-size:9pt;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;BEGIN  DECLARE CURS1 CURSOR FOR     SELECT CUSTNAME + 1 FROM MYLIB. MYTABLE      WHERE TELNO = REQKEY FOR UPDATE OF CUSTNAME;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="  white-space: normal; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Here's an example which creates a stored procedure in SQL for&lt;br /&gt;updating a table called MYTABLE.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;This has two fields; CustName and TelNo.  When called with a&lt;br /&gt;customer name,  it returns the phone number.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:arial;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt; CREATE PROCEDURE MYLIB.STOREDPROC         &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;(IN REQKEY CHARACTER(10),     INOUT RETVAL INTEGER )  &lt;br /&gt;RESULT SETS  0  &lt;br /&gt;LANGUAGE SQL    &lt;br /&gt;NOT DETERMINISTIC  &lt;br /&gt;/*Start of Procedure Code*/&lt;br /&gt;  BEGIN  /* Code always begins with 'Begin' */&lt;br /&gt;  DECLARE CURS1 CURSOR FOR&lt;br /&gt;    SELECT CUSTNAME + 1 FROM MYLIB. MYTABLE&lt;br /&gt;    WHERE TELNO = REQKEY&lt;br /&gt;FOR UPDATE OF CUSTNAME;   OPEN CURS1  ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;FETCH CURS1  INTO RETVAL ;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: x-small;"&gt;UPDATE MYLIB. MYTABLE SET CUSTNAME= RETVAL&lt;br /&gt;    WHERE CURRENT OF CURS1 ;  &lt;br /&gt; END&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;I'll cover calling these from .NET in more detail soon. &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;In the meantime, create yourself a simple Stored &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;procedure and try calling it. Then take one of  your&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; existing programs and replace your inline SQL &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;replacing it with a stored procedure.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"   style="  -webkit-border-horizontal-spacing: 20px; -webkit-border-vertical-spacing: 20px; font-family:'times new roman';font-size:12px;"&gt;&lt;pre class="code" style=""&gt;&lt;span class="Apple-style-span"  style=" ;font-family:georgia;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre class="code" style="font-family: monospace; font-size: 9pt; "&gt;&lt;br /&gt;&lt;/pre&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-8709761881843009381?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2009/06/how-to-create-stored-procedures.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-2576551624315482074</guid><pubDate>Sat, 23 May 2009 18:29:00 +0000</pubDate><atom:updated>2009-07-01T05:53:05.694-07:00</atom:updated><title>Learning to learn</title><description>&lt;p&gt;I have had more than a few emails from readers who privately moan that they 'just don't get it'. They find the concepts of object oriented programming too complex and wieldy and are unable to apply what they have learned in practice.&amp;#160; Despite having read the books, downloaded the software, written a few programs, they just don't feel competent. Not enough to use it daily in their work or even ace a simple test. They begin to feel as if they are past it, are simply unable to learn, old dogs/tricks etc. &lt;/p&gt;  &lt;p&gt;&lt;img alt="dumb-dog-crossing" src="http://smartdogs.files.wordpress.com/2009/01/dumb-dog-crossing.jpg?w=240&amp;amp;h=218" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Did the following happen to you?&lt;/strong&gt;&lt;/p&gt;  &lt;div&gt;You said you wanted to learn .NET so you went and bought the book. The first few chapters were simple. You grasped types and flow control. Foreach? no problem.&amp;#160; Hello World! I’m a C# programmer! Then you progressed into the depths of .Net.&amp;#160; Inheritance, interfaces, delegates, anonymous methods etc.&amp;#160; You understood this perhaps but you found it difficult to really do anything with them. You did the exercises and it just got worse. It took you a month to read one chapter. You found the whole thing hard, confusing, ridiculous, hard to apply to the real world and at the end you retained very little of what you learned. Four months later you retained NOTHING.    &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;Then you gave up.&lt;/div&gt;  &lt;div&gt;&lt;span style="font-weight: bold" class="Apple-style-span"&gt;Learning moment: You will not learn C# by reading a book.&lt;/span&gt; &lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;Don't despair!&amp;#160; Think about it - if you have been solving programming problems day in, day out throughout your career then&amp;#160; it stands to reason that you &lt;em&gt;still&lt;/em&gt; have all the right amount of grey matter. Yes! You're smart!&amp;#160; The problem may not be your programming skills, the problem may be your learning skills. This article describes the learning process and what you can do to improve your learning skills.     &lt;br /&gt;Quiz: By the end of this article try and answer this question: What learning activity was I (the writer) involved in by writing this piece?&lt;/div&gt;  &lt;div&gt;   &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;&lt;span style="font-weight: bold" class="Apple-style-span"&gt;Reading is not Doing&lt;/span&gt;&lt;/div&gt;  &lt;div&gt;&lt;span style="font-weight: bold" class="Apple-style-span"&gt;&lt;/span&gt;You can't learn C# solely from a book.&amp;#160;&amp;#160; Books are the abstract theory that form only part of the process. All the time you spend reading in earnest is just one of the activities required to really learn.&amp;#160; Simply reading a book on the subject (or this blog) is not enough. In fact there is a term for this approach- ‘surface learning’ and will likely end in failure. The reader makes the mistake that if they just read and do the exercises then it will all be absorbed like a sponge and magically they will become a .NET developer. Wrong.&amp;#160; Would you trust the novice captain of your transatlantic flight who spent hundreds of hours playing Microsoft Flight Simulator but never flew an actual plane?&amp;#160;&amp;#160; &lt;/div&gt;  &lt;div&gt;   &lt;br /&gt;&lt;strong&gt;Programming&lt;/strong&gt; &lt;strong&gt;is an experiential learning activity.&lt;/strong&gt;You may not have considered the change required to develop a completely new skill since you were at college.&amp;#160; If you are self-taught you may have forgotten that you did make a dramatic shift in thinking at the time. Well, this shift is required again because C# is a not just a different language, it’s a radically different way of programming.     &lt;br /&gt;It’s true that you learn all the time. At work you continually develop and enhance your skills but usually you are adding to existing knowledge through active experience and the learning is incremental. What is required now is to learn in a monumental manner&amp;#160; i.e understand, retain, practice and implement a complex new skill on a daily basis that is quite different than any you have acquired to date.&amp;#160;&amp;#160; &lt;br /&gt;To accomplish this you need to develop your learning skills. Once you really change your learning methods to adapt to acquiring new systems of thinking then you will find learning .Net or any similar hefty new skill much easier. This all takes substantial investment in time – more than you have likely done already. But if you take the smart approach it will really pay off , you will retain what you have learned and importantly, be able to apply it to daily programming problems. You might have spent months reading C# books without being able to use it practically, so spending the extra time learning to learn will salvage precious time spent reading. So the hard part is not C#, the hard part is changing how you learn. Let’s look now at what learning really is.&lt;/div&gt;  &lt;div&gt;Look at the diagram below by the experiential learning guru David Kolb - it shows the various stages of learning. Now tell me where your $50 C# book is in this cycle?&amp;#160; (I have to laugh at the SAM’S programming titles ‘Learn C# in 24 hours’ ).&amp;#160; Programming does not mean coding, SAM. Programming means being able to take a customer problem – like a business request for multi country order entry and turn it into a solution using the appropriate programming language. Knowing the definition of a Lambda expression is much different than knowing exactly how to apply it in the search function in the order history module and why.&amp;#160; &lt;/div&gt;  &lt;div&gt;The stages of learning then are:&lt;/div&gt;  &lt;ol&gt;   &lt;li&gt;Abstract Conceptualization &amp;amp; Theory (Books, blogs, articles, lectures)&lt;/li&gt;    &lt;li&gt;Active Experimentation (Applying what you have learned in different situations)&lt;/li&gt;    &lt;li&gt;Concrete Experience (Doing a real life project in C#)&lt;/li&gt;    &lt;li&gt;Reflection (Complete and go back over your experience documented in your learning journal to change your future behaviour.)&lt;/li&gt; &lt;/ol&gt;  &lt;div&gt;So yes, you need the book but you need to remember that learning C# is not just about reading a book and understanding the concepts. It is a major shift in thinking which requires monumental learning.&amp;#160; You read the book but because you weren’t successful and couldn’t apply it you thought .NET and C# was just beyond you. It’s not. You just didn’t complete the other 3 parts of learning.&amp;#160; &lt;img src="http://www.ilough-lab.com/files/kolb.JPG" /&gt;     &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;But Kolb doesn't say HOW you learn in a monumental way.&amp;#160; Let’s turn now to improving your learning skills.&lt;/div&gt;  &lt;div&gt;One proven method for developing learning skills comes from clinical practice- 'Reflection ON Action and Reflection IN action' according to Price &amp;amp; Maier in their excellent book &lt;a href="http://www.pearsoned.co.uk/Bookshop/detail.asp?item=100000000226493"&gt;‘Effective Study Skills’&lt;/a&gt; (Pearson 2007).&amp;#160; This reflection process means to systematically monitor your learning while on a task and after the task. &lt;/div&gt;  &lt;div&gt;You will need to add about 10-20% of your time for each task to monitor it through the process called 'Reflection'.    &lt;br /&gt;Don’t skip this! You probably think ‘I don’t need to be this explicit, I know all this stuff already’. I agree, you do know this stuff, but you know it &lt;em&gt;implicitly&lt;/em&gt;. The point is to improve your learning and to do that, your knowledge needs to become more &lt;em&gt;explicit&lt;/em&gt;.&amp;#160; Engineers are notorious for being black holes of knowledge. It all goes in but nobody , including themselves, sees clearly into that obscure mass of synaptic lightning. They scoff at others who are ‘all talk and no action’ they find articulation beneath them. They hide in their cubicle and weeks later magic stuff appears on screens. The reality is that we all need to be a little more ‘all talk’&amp;#160; to learn with skill, speed and be able to quickly put it into practice. If we want to keep making magic stuff, we need to articulate our learning, we need to learn how to be reflective. &lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;&lt;strong&gt;Reflection &lt;/strong&gt;is a process whereby you mirror the activities you are engaged in, think about them objectively and determine ways to change your behaviour and then actively apply the changes in your behaviour. &lt;/div&gt;  &lt;div&gt;You can start using reflection today. Let’s take a typical project like order entry.&lt;/div&gt;  &lt;div&gt;Here’s the three steps to reflection:&lt;/div&gt;  &lt;div&gt;1) &lt;strong&gt;Recap&lt;/strong&gt;: Go back over the requirements, how they changed during coding, what delayed the project. Go back over what happened. Articulate the project issues and how they were solved or not solved. Articulate doesn’t mean glossing it over in your head, it means writing it down, presenting it to others, chunk the information in meaningful ways, use mindmaps to look for patterns.&lt;/div&gt;  &lt;div&gt;2) &lt;strong&gt;Reframe&lt;/strong&gt;: Take what you have learned and apply it in a new situation.     &lt;br /&gt;If the requirements changed substantially during coding then the     &lt;br /&gt;A simple example comes from language learning. You take a word and then use it in a new sentence.&lt;/div&gt;  &lt;div&gt;3) &lt;strong&gt;Reassess&lt;/strong&gt;: This is a biggie. Here you need to determine how to change your behaviour and activity based on what you learned. You may have noticed that some problems go from project to project. Don’t blame it all on upper management, the users, budget etc. Figure out where you can specifically change your behaviour in the next project and then commit to change. e.g. Create minutes after every meeting so everyone is clear as to their responsibilities. &lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;Remember, the process of reflection happens IN action and AFTER the action. Keep a journal to track your learning (see below).&lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;I recommend a few things to retool your learning.&lt;/div&gt;  &lt;div&gt;1) &lt;strike&gt;Read&lt;/strike&gt; Study the book ‘&lt;a href="http://www.pearsoned.co.uk/Bookshop/detail.asp?item=100000000226493"&gt;Effective Study Skills'&lt;/a&gt; by Price &amp;amp; Maier (Pearson Press) &lt;/div&gt;  &lt;div&gt;2) Take a study course at your local university or college. Learn to Learn!&lt;/div&gt;  &lt;div&gt;3) Keep a notebook on learning. Track your learning like a kind of resume. State your current ability in the various areas of .NET, state your objectives VERY specifically (e.g. be able to write any subfile type program in ASP.NET in under 6 hours).&amp;#160;&amp;#160; &lt;/div&gt;  &lt;div&gt;   &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;I'm only lightly touching on the subject here but take comfort in the fact that you're not dumb, that you CAN learn, and you will be a great .NET developer because you are a great iSeries developer. However you can and you must change. Yes, dog/spots, you can change -&amp;#160; through improving your learning.&amp;#160; Most programmers are self-taught and when they come up with a learning block they stop right there because they have only learned one way. What they forget is that there are lots of ways to learn. You owe it to yourself to improve your learning, to adapt to what is changing around you.&amp;#160; Don’t bank on learning C'# just one way. Take a class. Get a junior position in a .NET team (even if you are 48) and get adopted by a guru (even if he’s 25). Have learning as a systematic process and core part of ALL your activities. Reflect on your learning.&amp;#160; OK, try and do it right now. Go through this article again to reflect i.e. Recap, reframe and reassess.&lt;/div&gt;  &lt;div&gt;&lt;img src="http://www.microvision.com/displayground/wp-content/uploads/2009/01/brainfire.jpg" width="153" height="153" /&gt;    &lt;br /&gt;&lt;/div&gt;  &lt;div&gt;An efficient learning process is essential for your continued professionalism. Look at Dice.com and see where all the jobs are - in newer technologies like .NET.&amp;#160;&amp;#160; In 10 years it will be completely transformed again and you will need to change again. Becoming a proficient learner is just another skill but is undoubtedly the greatest skill of all. &lt;/div&gt;  &lt;div&gt;&amp;#160;&lt;/div&gt;  &lt;div&gt;&lt;font size="1"&gt;&lt;em&gt;The information on learning in this article is partly based on Price &amp;amp; Maier’s book ‘&lt;/em&gt;&lt;/font&gt;&lt;a href="http://www.pearsoned.co.uk/Bookshop/detail.asp?item=100000000226493"&gt;&lt;font size="1"&gt;&lt;em&gt;Effective Study Skills'&lt;/em&gt;&lt;/font&gt;&lt;/a&gt;&amp;#160; &lt;br /&gt;&lt;font size="1"&gt;     &lt;br /&gt;&lt;/font&gt;&lt;/div&gt;  &lt;div&gt;   &lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-2576551624315482074?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2009/05/learning-to-learn.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-6387817853256471220</guid><pubDate>Sun, 10 May 2009 21:45:00 +0000</pubDate><atom:updated>2009-06-23T14:55:43.342-07:00</atom:updated><title>Fast Paging a .NET grid from an iSeries table</title><description>I recently wrote a simple grid view ASP.NET web application for a client displaying late paying customers. The SQL behind it though had to summarize and group across several different tables on the iSeries. The program worked well but the client complained that the app took too long to start up.&lt;div&gt;To speed things up, I put all the SQL into a stored procedure used a scrollable cursor and fetched 22 records at a time.  &lt;span class="Apple-style-span" style="font-family: Verdana; font-size: 13px; line-height: 16px; "&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 102, 0);"&gt;FETCH NEXT FROM C1 FOR 22 ROWS&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;I shouldn't have done a select All - it took too long and left the customer hanging even though there wasn't much data behind it. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-6387817853256471220?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2009/05/fast-paging-net-grid-from-iseries-table.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-8355094934977314126</guid><pubDate>Thu, 02 Apr 2009 17:56:00 +0000</pubDate><atom:updated>2009-04-02T10:56:56.445-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">as/400</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">books</category><title>Books on writing C# apps for iSeries</title><description>&lt;p&gt;One of the reasons I started this blog was to periodically build up enough material for a book on interfacing the iSeries with .NET&lt;/p&gt;  &lt;p&gt;Someone has already done this - written a book, I mean. It's called &amp;quot;Develop Microsoft C# Applications for the iSeries&amp;quot; by Craig Pelke. They are priced towards IT departments at $445 not&amp;#160; for recession babies like you and me. &lt;/p&gt;  &lt;p&gt;He's written&amp;#160; a bunch of books about .NET and the iSeries, so if you have got any of them - please let me know what they are like.&lt;/p&gt;  &lt;p&gt;Here's a link to where you can buy them&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www2.systeminetwork.com/str/books/UniqueAuthor.cfm?NextAuthor=150" href="http://www2.systeminetwork.com/str/books/UniqueAuthor.cfm?NextAuthor=150"&gt;http://www2.systeminetwork.com/str/books/UniqueAuthor.cfm?NextAuthor=150&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-8355094934977314126?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2009/04/books-on-writing-c-apps-for-iseries.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-1651773923571862702</guid><pubDate>Wed, 25 Mar 2009 22:03:00 +0000</pubDate><atom:updated>2009-06-23T15:17:49.200-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">asp.net</category><title>What is ASP.NET?</title><description>&lt;div&gt;&lt;div&gt;ASP.NET is the platform to create web pages in .NET. &lt;/div&gt;&lt;div&gt;We say 'I'm writing this app in ASP.NET' to indicate the technologies used.&lt;/div&gt;&lt;div&gt;To create an ASP.NET page, open up Visual Studio and create it from there.&lt;/div&gt;&lt;div&gt;I would then use C# as the code with HTML to provide the controls to process the page.&lt;/div&gt;&lt;div&gt;That code is either embedded in the web page code itself or included in a separate file.&lt;/div&gt;&lt;div&gt;When embedded, it is called INLINE, when separate it is called CODE-BEHIND.&lt;/div&gt;&lt;div&gt;I prefer to use code behind since it keeps the application logic separate.&lt;/div&gt;&lt;div&gt;Visual Studio saves an ASP.NET file as .apx page type.&lt;/div&gt;&lt;div&gt;A web config file is part of the files in your application which contains your connection string to the iSeries.&lt;/div&gt;&lt;div&gt;ASP.NET may seem daunting and the mix of html and C# makes it especially so. The number of files generated by Visual Studio may seem excessive but the aspx and web config are the ones to focus on.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-1651773923571862702?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2009/03/what-is-aspnet.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-6159930830689474738</guid><pubDate>Mon, 22 Sep 2008 22:57:00 +0000</pubDate><atom:updated>2008-09-22T15:59:01.692-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.net data provider</category><category domain="http://www.blogger.com/atom/ns#">db2 .net data provider</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">SQL</category><title>Connection String Stinger - Phantom Library List</title><description>&lt;p&gt;.Net can look for your tables in a library the same name as your user id&amp;#160; even if you supply a library list. This can cause your SQL 'selects' to fail.&lt;/p&gt;  &lt;p&gt;Take a look:   &lt;br /&gt;Here's a basic connection string using the IBM supplied iDB2 Classes:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;DataSource=192.168.0.1; UserID=colm;Password=xxxx;LibraryList= CusLib,ARlib, QGPL&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;At first glance everything looks good, right?&lt;/p&gt;  &lt;p&gt;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?&amp;#160; - A big fat error like this:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;SQL0204 - File MYCSUT in COLM not found&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;What??. &lt;em&gt;CusLib&lt;/em&gt; is on the TOP - I don't even mention library Colm.&amp;#160; What's going on?&lt;/p&gt;  &lt;p&gt;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&lt;/p&gt;  &lt;p&gt;Here's the new connection string&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;DataSource=192.168.0.1; UserID=colm;Password=xxxx;LibraryList= CusLib,ARlib, QGPL;DefaultCollection=CUSLIB&lt;/strong&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-6159930830689474738?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/09/connection-string-stinger-phantom.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-8410331283636295258</guid><pubDate>Fri, 12 Sep 2008 20:57:00 +0000</pubDate><atom:updated>2008-09-12T14:00:26.111-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">console applications</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">File System</category><category domain="http://www.blogger.com/atom/ns#">batch files</category><title>How to run your .net batch programs without showing a dos screen</title><description>&lt;p&gt;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.&lt;/p&gt;  &lt;p&gt;There are a couple of ways to prevent the DOS screen flashing up every time your program runs. Here's a simple way:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a batch file (Myapp.bat for example) to run your app.&lt;/li&gt;    &lt;li&gt;Create a shortcut (.lnk) to Myapp.bat &lt;/li&gt;    &lt;li&gt;Right click on the shortcut and select &lt;strong&gt;Properties&lt;/strong&gt;&lt;/li&gt;    &lt;li&gt;Change the drop down for &lt;strong&gt;Run&lt;/strong&gt; from Normal to Minimized&lt;/li&gt;    &lt;li&gt;Now run your shortcut. The dos screen should not appear and the program should appear on your taskbar as it runs.&lt;/li&gt;    &lt;li&gt;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 prompt&lt;a href="http://lh3.ggpht.com/hollywoodsign/SMrYYbeThcI/AAAAAAAAAL4/qQWYtkom4mI/s1600-h/image%5B10%5D.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="427" alt="image" src="http://lh4.ggpht.com/hollywoodsign/SMrYZEmNjRI/AAAAAAAAAL8/Vw7KMkY_jhE/image_thumb%5B6%5D.png?imgmax=800" width="383" border="0" /&gt;&lt;/a&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-8410331283636295258?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/09/how-to-run-your-net-batch-programs.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-4421332948432539180</guid><pubDate>Sat, 23 Aug 2008 01:42:00 +0000</pubDate><atom:updated>2008-09-12T18:42:43.413-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">news</category><category domain="http://www.blogger.com/atom/ns#">legacy conversion</category><category domain="http://www.blogger.com/atom/ns#">.net</category><title>iSeries Users prefer .NET to Websphere/Java</title><description>&lt;p&gt;At the annual ASNA conference a poll amongst users report that .NET is the way to go and Java is on the way out.&amp;#160; According to the press release &amp;quot;An overwhelming majority of conference attendees stated that .NET offered a better environment than WebSphere/Java for transforming critical corporate applications running on legacy iSeries systems and built with RPG code.&amp;quot;&lt;/p&gt;  &lt;p&gt;Read more at:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.businesswire.com/portal/site/google/index.jsp?ndmViewId=news_view&amp;amp;newsId=20050614005836&amp;amp;newsLang=en"&gt;iSeries Users Overwhelmingly Embrace .NET At ASNApalooza&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-4421332948432539180?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/08/iseries-users-prefer-net-to.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-4855251968795550737</guid><pubDate>Thu, 07 Aug 2008 21:46:00 +0000</pubDate><atom:updated>2008-08-08T12:51:20.201-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">ado.net</category><category domain="http://www.blogger.com/atom/ns#">db2 .net data provider</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">db2</category><title>How to video: Access data on iSeries using ADO.NET</title><description>&lt;p&gt;Here is a super simplified video example of a C# application reading from a table on an iSeries. It uses the IBM .net managed provider (See &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/01/different-ways-to-access-iseries-data.html" target="_blank"&gt;Different ways to access iSeries data&lt;/a&gt; and &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/01/where-to-get-iseries-adonet-data.html" target="_blank"&gt;this&lt;/a&gt;) . You have this&amp;#160; if you have IBM Client Access. If not, download the technology preview &lt;a href="http://www-03.ibm.com/systems/i/software/access/windows/tech_preview.html"&gt;here&lt;/a&gt;. Sound problem? jiggle the player control if the sound goes out (I'm trying out demo utility software let me know what one you use.)     &lt;br /&gt;.     &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/video/Accessing%20iSeries%20data%20from%20.NET%20using%20C%23-output/Accessing%20iSeries%20data%20from%20.NET%20using%20C%23.swf"&gt;&lt;img style="cursor: pointer" alt="" src="http://www.aranrock.com/C_sharp_for_RPG_Programmers/uploaded_images/flash-image-for-tutorial-733100.jpg" border="0" /&gt;&lt;/a&gt;     &lt;br /&gt;To view the video click &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/video/Accessing%20iSeries%20data%20from%20.NET%20using%20C%23-output/Accessing%20iSeries%20data%20from%20.NET%20using%20C%23.swf"&gt;here&lt;/a&gt;.     &lt;br /&gt;    &lt;br /&gt;To download the project used in the video, click &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/video/Accessing%20iSeries%20data%20from%20.NET%20using%20C%23-output/iSeriesADOexample.rar"&gt;here&lt;/a&gt;.    &lt;br /&gt;    &lt;br /&gt;&lt;a href="http://feeds.feedburner.com/DotNetFlukeZoo" target="_blank"&gt;Subscribe&lt;/a&gt; to DotNetFluke to receive weekly useful tips for integrating .NET with the iSeries.     &lt;br /&gt;If you have any iSeries/.NET integrations questions or suggestions for articles email me at &lt;a href="mailto:cbyrne+blog@AranRock.com"&gt;cbyrne+blog@AranRock.com&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-4855251968795550737?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/01/how-to-video-access-data-on-iseries.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-4821925283723407601</guid><pubDate>Tue, 05 Aug 2008 15:50:00 +0000</pubDate><atom:updated>2008-08-05T10:17:09.148-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">visual studio</category><category domain="http://www.blogger.com/atom/ns#">Comparison</category><category domain="http://www.blogger.com/atom/ns#">Tools</category><category domain="http://www.blogger.com/atom/ns#">iseries</category><title>Converting RPG code to C# automatically?</title><description>&lt;p&gt;What if you could take&amp;#160; your RPG programs and hey presto! have them converted into .NET and instantly sell your product to the rest of the world.&amp;#160;&amp;#160; This would be a boon to AS/400 vendors locked into the small(ish) AS/400 market.&amp;#160;&amp;#160; The advantage is that the original product is likely&amp;#160; a mature business proven system which can provide a critical edge against the deluge of competition once in the new windows space.&amp;#160; While&amp;#160; webfacing does provide a web front end to applications and is great for hosted models it does not help customers who are windows only and want windows only software.   &lt;br /&gt;    &lt;br /&gt;Granted companies need to migrate on the competition level . However, all the supposed advantages such as performance, cost savings, availability of talent etc sounds hollow to long time AS/400 owners. Anecdotally we know that the uptime for the AS/400 is absolutely stunning compared to windows.&amp;#160; It's super stable and extremely reliable. At windows only shops instead of maintaining one iSeries server&amp;#160; and a handful of windows server you end&amp;#160; up maintaining 20-30 windows servers for a small organization.&amp;#160; But like I said, it's about getting your product out to a bigger market.     &lt;br /&gt;A big issue with migration products is that often your migrated solution will not be able to operate without them. Yikes!&amp;#160; &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;I'll be doing a review of these migration products once I get my hands on them but in the meantime here's an overview. Click the title to go to the product website.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.transoft.com" target="_blank"&gt;TranSoft ML-Impact&lt;/a&gt;&amp;#160; &lt;br /&gt; Well, the boys and girls at TranSoft claim that they can convert your old F-specs, c-specs to .NET .&amp;#160;&amp;#160; I would love to see the code generated (post a sample&amp;#160; in comments pleez). They claim that CL and RPG will be converted to C#. Not only that they can take the DB2 tables and migrate them to SQL server. Not everything can be converted directly of course and the end result looks much like a 5250 application.    &lt;br /&gt;Without having the product available to me I can't give it the thumbs up or down&amp;#160; but if you have any experience with this tool, please drop a comment.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.adcaustin.com" target="_blank"&gt;ADC Austin&lt;/a&gt;    &lt;br /&gt;Remember Synon? The hot product of 20 years ago is now trying to be cool.&amp;#160; They have jiggered a way to migrate from CA2E (Synon)&amp;#160; to Plex which uses .NET.&amp;#160;&amp;#160; Sounds complicated. If you've tried it, drop me a line.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.asna.com" target="_blank"&gt;ASNA Monarch and AVR for .NET&lt;/a&gt;    &lt;br /&gt;ASNA monarch is a code converter that&amp;#160; creates RPG for .NET while AVR is a Visual Studio add-in that allows RPG&amp;#160; for .NET (an ASNA creation) development and compiles as a .net app.&amp;#160;&amp;#160; Seems like these two products have the same product base.&amp;#160; The only feedback I've seen on this product is that there is no code completion, no automatic layout and ctl-z doesn't work.&amp;#160; Your comments pls.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.lansa.com" target="_blank"&gt;Lansa Ramp&lt;/a&gt; and the rest    &lt;br /&gt;There are a bunch of other sticky migration tools out there that are designed to keep you using their applications. While the products above are somewhat sticky you can still migrate off them.&amp;#160; Products like the Lansa Ramp platform is a staged migration solution that requires you to develop a an application framework using their tools, prototype it, then recreate your screens in that framework. However the end product is a Lansa architecture that you have to stick with for the rest of eternity.&amp;#160; &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-4821925283723407601?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/08/converting-rpg-code-to-c-automatically.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">5</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-7283032802492946523</guid><pubDate>Wed, 30 Jul 2008 21:05:00 +0000</pubDate><atom:updated>2008-07-30T14:05:01.514-07:00</atom:updated><title>Reading a C# Grid (Reading a subfile)</title><description>&lt;p&gt;Previously I discussed how to write records to a C# grid -&amp;#160; the equivalent of an RPG subfile. But how do you read those records? Say you wanted to add totals entered to store in another table?&lt;/p&gt;  &lt;p&gt;You might recall that unlike in RPG where we read a table and write each record from the table directly to a subfile, C# creates a layer between the physical data and the grid by using a data set. This is handy because you don't have to worry about updating multiple tables every time an update/add or delete is made to the grid, this is handled automatically when you define what tables belong to the data set. &lt;/p&gt;  &lt;p&gt;Here is some code we used before to fill a data set:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="rem"&gt;// build a command object and prepare an SQL statement so that you can look at your table &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;SqlCommand buildData = conn.CreateCommand(); &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;cmd.CommandText = &lt;span class="str"&gt;&amp;quot;Select * from Orders where OrdQty &amp;gt;100&amp;quot;&lt;/span&gt;; &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="rem"&gt;// Build the Data Adapater - this fills a data set &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;SqlDataAdapter dataAdapter = &lt;span class="kwrd"&gt;new&lt;/span&gt; SqlDataAdapter(buildData); &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="rem"&gt;// Now create the data set. The data structure which contains the data retrieved by the data adapter &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;DataSet orderDataSet = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataSet(); &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="rem"&gt;// Populate the dataset with the Data Adapter &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;dataAdapter.Fill(dataSet);&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&amp;#160;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The data set defined above would be 'bound' to a grid as follows&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;DataGridView1.DataSource = ds.Tables.Item(0)&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now when the grid is displayed it will display orders from Orders file through the layer of the data set. Any changes made to the grid would be reflected in the data set.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To update the database simply use the adapater's update method&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt; &lt;span class="kwrd"&gt;this&lt;/span&gt;.custTableAdapter.Update(ds DataSet);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;font face="Tahoma" color="#555544"&gt;&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;font face="Tahoma" color="#555544"&gt;But back to our original question, how do you read the data in the data set for processing?&lt;br /&gt;&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;font face="Tahoma" color="#555544"&gt;In RPG you could read each record in the subfile in a DOW loop, in C# you can use the For Each loop&lt;br /&gt;&lt;br /&gt;which can read through data set as follows.&lt;/font&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;  &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (DataRow rowx &lt;span class="kwrd"&gt;in&lt;/span&gt; ds.Tables(0))&lt;br /&gt;            {&lt;br /&gt;                 totalInnings = totalInnings + rowx[&lt;span class="str"&gt;&amp;quot;Innings&amp;quot;&lt;/span&gt;];&lt;br /&gt;            }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The foreach statement is a powerful construct and makes processing data extremely simple. The above statement will process all the records in the subfile &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:a2928a7f-ab92-4862-bee4-33648c440ffe" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/Data%20Set" rel="tag"&gt;Data Set&lt;/a&gt;,&lt;a href="http://technorati.com/tags/ado.net" rel="tag"&gt;ado.net&lt;/a&gt;,&lt;a href="http://technorati.com/tags/foreach" rel="tag"&gt;foreach&lt;/a&gt;,&lt;a href="http://technorati.com/tags/table%20adapter" rel="tag"&gt;table adapter&lt;/a&gt;,&lt;a href="http://technorati.com/tags/dataset" rel="tag"&gt;dataset&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;and any processing just has to occur in between the curly brackets.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-7283032802492946523?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/07/reading-c-grid-reading-subfile.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-5253842495790735712</guid><pubDate>Wed, 16 Jul 2008 04:59:00 +0000</pubDate><atom:updated>2008-08-05T09:55:00.093-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">File System</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">iseries access</category><title>Read, write and delete files in windows</title><description>&lt;p&gt;Sooner or later you'll need to access files from the Window's file system. You'll need to check if a file exists, delete it, move it&amp;#160; , you'll need to read and write to it and upload data from it to an iSeries table etc.&lt;/p&gt;  &lt;p&gt;To illustrate how easy this is, I've included a full C# project.&lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;This program cleans up a desktop. It moves unwanted items automatically to a 'clean up' folder automatically. Items you don't want to remove are maintained in a text file manually. This file is in 'CleanUp' on your desktop after you run it the first time.     &lt;br /&gt;Set it up to run in 'scheduled tasks' to run daily. My desktop gets absolutely splattered with downloads, images, files etc. etc.&amp;#160; Now it gets cleaned automatically and the stuff I want to keep is always there. Files are moved but not folders.&amp;#160; &lt;/p&gt;  &lt;p&gt;   &lt;br /&gt;The app demonstrates two things. &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;How to access the windows file system &lt;/li&gt;    &lt;li&gt;How to write a RPG-like app in C#. i.e. in a procedural way&amp;#160; There is a 'main', an init etc. There are no class objects created, everything runs from the class. Methods are just like subroutines. Variables are defined that are needed throughout the application as public at the top of the class. (If you define a variable in a method - it is only available within that method.)&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Please improve on this app and sent it back to share!&lt;/p&gt;  &lt;p&gt;Download the attached visual studio project from &lt;a href="http://www.aranrock.com/apps" target="_blank"&gt;here&lt;/a&gt;. (VS 2008)     &lt;br /&gt;If you just want the program executable itself download it &lt;a href="http://www.aranrock.com/apps" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Security.Principal;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="rem"&gt;//Lists each object on the desktop&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;//Checks if the object is in the list.&lt;/span&gt;&lt;br /&gt;&lt;span class="rem"&gt;//If not, moves it to cleanup.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; ClearDesktop&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br /&gt;    {&lt;br /&gt;       &lt;br /&gt;  &lt;span class="rem"&gt;// Declare class level variables that are accessible from all methods&lt;/span&gt;&lt;br /&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; cleanUpFolder = &lt;span class="str"&gt;@&amp;quot;Cleanup\&amp;quot;;&lt;br /&gt;        public static string desktopPathAllUsers = @&amp;quot;&lt;/span&gt;C:\Documents and Settings\All Users\Desktop\&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;        public static string desktopPath = &amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;        public static string cleanUpPath = &amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;        public static string cleanUpFile = &amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;        public static string allowedOnDesktop = &amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;       &lt;br /&gt;        &lt;br /&gt;        &lt;br /&gt;  // Main Routine     &lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            initializationRoutine();  // Set paths needed&lt;br /&gt;       &lt;br /&gt;            RemoveFilesFromDesktop(desktopPath); // remove unwanted files&lt;br /&gt;            RemoveFilesFromDesktop(desktopPathAllUsers); // some file paths are in 'all users'&lt;br /&gt;        //    Console.ReadLine();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    public static void RemoveFilesFromDesktop(string dir)&lt;br /&gt;        {&lt;br /&gt;// First create directory object from the desktop path&lt;br /&gt;        DirectoryInfo mainDir = new DirectoryInfo(dir);&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;// This single line fills an array called 'items' of everything on the desktop&lt;br /&gt;  &lt;br /&gt; // The items in the array are not strings but FileSystemInfo objects. &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;// What's cool here is each item has a ton of methods and properties &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; // available directly from it.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="str"&gt;            FileSystemInfo[] items = mainDir.GetFileSystemInfos();&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="str"&gt;&lt;br /&gt;// Now go through each item in the array and check if it is allowed&lt;br /&gt;            foreach (FileSystemInfo item in items)&lt;br /&gt;            {&lt;br /&gt;                // Check if the file on the desktop is in the 'allowed' file&lt;br /&gt;                bool allowedyn =  allowedOnDesktop.Contains(item.Name.ToString());&lt;br /&gt;                &lt;br /&gt;                if (item is FileInfo &amp;amp;&amp;amp; !allowedyn)&lt;br /&gt;                {&lt;br /&gt;                   // If it is to be moved any existing same name file has to be deleted&lt;br /&gt;                    String alreadyExists = cleanUpPath + item;&lt;br /&gt;&lt;br /&gt;                    if (File.Exists(alreadyExists))&lt;br /&gt;                    {&lt;br /&gt;                        try&lt;br /&gt;                        {&lt;br /&gt;                            // Delete the file with the same name &lt;br /&gt;                            File.Delete(alreadyExists);&lt;br /&gt;                        }&lt;br /&gt;                        catch (Exception)&lt;br /&gt;                        {&lt;br /&gt;                            &lt;br /&gt;                            &lt;br /&gt;                        }&lt;br /&gt;                        &lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                    // Move the file on the desktop to the clean up folder&lt;br /&gt;                    ((FileInfo)item).MoveTo(cleanUpPath + item);&lt;br /&gt;                &lt;br /&gt;                }&lt;br /&gt;             &lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;&lt;br /&gt;            &lt;br /&gt;      &lt;br /&gt;        // Get a list of all the files allowed on the desktop&lt;br /&gt;          public static string WhatsAllowedOnTheDesktop(string logFileName)&lt;br /&gt;        {&lt;br /&gt;            &lt;br /&gt;            string contents = &amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt;            using (FileStream fileStream = new FileStream(logFileName,&lt;br /&gt;                        FileMode.Open,&lt;br /&gt;                        FileAccess.Read,&lt;br /&gt;                        FileShare.None))&lt;br /&gt;            {&lt;br /&gt;                using (StreamReader Reader = new StreamReader(fileStream))&lt;br /&gt;                {&lt;br /&gt;                    contents = Reader.ReadToEnd(); // Reads the entire file in one statement&lt;br /&gt;                    Reader.Close();&lt;br /&gt;                    fileStream.Close();&lt;br /&gt;                }&lt;br /&gt;                &lt;br /&gt;               &lt;br /&gt;            }&lt;br /&gt;            return contents;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Write to the 'Allowed files' directory those files you don't want to move&lt;br /&gt;          public static void WriteToLog(string logFileName, string data)&lt;br /&gt;          {&lt;br /&gt;              using (FileStream fileStream = new FileStream(logFileName,&lt;br /&gt;                      FileMode.Append,&lt;br /&gt;                      FileAccess.Write,&lt;br /&gt;                      FileShare.None))&lt;br /&gt;              {&lt;br /&gt;                  using (StreamWriter streamWriter = new StreamWriter(fileStream))&lt;br /&gt;                  {&lt;br /&gt;                      streamWriter.WriteLine(data);&lt;br /&gt;                  }&lt;br /&gt;              }&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;        // Do basic setup - path names etc.&lt;br /&gt;        public static void initializationRoutine() {&lt;br /&gt;              string username = getUserName();&lt;br /&gt;             &lt;br /&gt;            desktopPath = @&amp;quot;&lt;/span&gt;C:\Documents and Settings\&lt;span class="str"&gt;&amp;quot; + username + @&amp;quot;&lt;/span&gt;\Desktop\&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;            cleanUpPath  = desktopPath + cleanUpFolder;&lt;br /&gt;            cleanUpFile = cleanUpPath + @&amp;quot;&lt;/span&gt;CleanUpFile.txt&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;&lt;br /&gt;            //  If the cleanup directory does not exist, create it&lt;br /&gt;            if (!Directory.Exists(cleanUpPath))&lt;br /&gt;            {&lt;br /&gt;                Directory.CreateDirectory(cleanUpPath);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            // Create the log file of items you want to keep on the desktop &lt;br /&gt;            &lt;br /&gt;            if (!File.Exists(cleanUpFile))&lt;br /&gt;            {&lt;br /&gt;                File.Create(cleanUpFile);&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;            allowedOnDesktop = WhatsAllowedOnTheDesktop(cleanUpFile);&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;        // Get the log on name of the user who started the app in order&lt;br /&gt;        // to know the path of their desktop&lt;br /&gt;        public static string getUserName()&lt;br /&gt;        {&lt;br /&gt;            WindowsIdentity ident = WindowsIdentity.GetCurrent();&lt;br /&gt;&lt;br /&gt;            string userid = ident.Name;&lt;br /&gt;            string username = &amp;quot;&lt;/span&gt;&lt;span class="str"&gt;&amp;quot;;&lt;br /&gt;            int pos = userid.IndexOf(&amp;quot;&lt;/span&gt;\\&amp;quot;);&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (pos &amp;gt; -1)&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                username = userid.Substring(pos + 1);&lt;br /&gt;            }&lt;br /&gt;            &lt;span class="kwrd"&gt;else&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;                username = userid;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; username;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-5253842495790735712?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/07/read-write-and-delete-files-in-windows.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-8641476453912205942</guid><pubDate>Mon, 07 Jul 2008 23:02:00 +0000</pubDate><atom:updated>2008-08-05T12:34:24.403-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">RPG vs C#</category><category domain="http://www.blogger.com/atom/ns#">iseres</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">RPG</category><title>When a method calls itself</title><description>&lt;p&gt;This you can't do in RPG - have a method call itself. Sounds like something you would never use? Think again.&lt;/p&gt;  &lt;p&gt;See this small console program that recurses through directories to get a list of folders and files. When the method finds a directory, it calls itself with the sub folder as a parameter whereupon the File part of the IF statement is executed. &lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; ConsoleApplication1&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;        {&lt;br /&gt;            Recurse(&lt;span class="str"&gt;@&amp;quot;c:\temp&amp;quot;&lt;/span&gt;);&lt;br /&gt;        }&lt;br /&gt;       &lt;br /&gt;               &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Recurse(&lt;span class="kwrd"&gt;string&lt;/span&gt; directory)&lt;br /&gt;    {&lt;br /&gt;        DirectoryInfo path = &lt;span class="kwrd"&gt;new&lt;/span&gt; DirectoryInfo(directory);&lt;br /&gt;        FileSystemInfo[] files = path.GetFileSystemInfos( );&lt;br /&gt;        &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (FileSystemInfo file &lt;span class="kwrd"&gt;in&lt;/span&gt; files)&lt;br /&gt;        {&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (file &lt;span class="kwrd"&gt;is&lt;/span&gt; DirectoryInfo)&lt;br /&gt;            { &lt;br /&gt;                Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Folder-&amp;gt; &amp;quot;&lt;/span&gt; + ((DirectoryInfo)file).FullName);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;font size="3"&gt;&lt;font color="#008000"&gt;// Now the method calls itself passing in the subfolder name. When the method is called&lt;br /&gt;all the files in the subfolder are listed&lt;/font&gt; &lt;br /&gt;               &lt;font size="4"&gt;&lt;strong&gt; &lt;font color="#ff0000"&gt;Recurse(((DirectoryInfo)file).FullName);&lt;/font&gt;&lt;/strong&gt;&lt;/font&gt;&lt;br /&gt;&lt;/font&gt;            }&lt;br /&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (file &lt;span class="kwrd"&gt;is&lt;/span&gt; FileInfo)&lt;br /&gt;            {&lt;br /&gt;                Console.WriteLine(&lt;span class="str"&gt;&amp;quot;File-&amp;gt; &amp;quot;&lt;/span&gt; + ((FileInfo)file).FullName); &lt;br /&gt;            } &lt;br /&gt;            &lt;br /&gt;        }&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:9e076f28-3434-4eb5-862d-7e2fe6a19ff6" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;LiveJournal Tags: &lt;a href="http://www.livejournal.com/interests.bml?int=recursion" rel="tag"&gt;recursion&lt;/a&gt;,&lt;a href="http://www.livejournal.com/interests.bml?int=i/o" rel="tag"&gt;i/o&lt;/a&gt;,&lt;a href="http://www.livejournal.com/interests.bml?int=filesystem" rel="tag"&gt;filesystem&lt;/a&gt;,&lt;a href="http://www.livejournal.com/interests.bml?int=directory" rel="tag"&gt;directory&lt;/a&gt;,&lt;a href="http://www.livejournal.com/interests.bml?int=folders" rel="tag"&gt;folders&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-8641476453912205942?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/07/when-method-calls-itself.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-4685009344255823477</guid><pubDate>Fri, 27 Jun 2008 14:45:00 +0000</pubDate><atom:updated>2008-07-31T07:59:20.540-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">SQL</category><category domain="http://www.blogger.com/atom/ns#">db2</category><title>SQL Crib Sheet for iSeries and .NET</title><description>&lt;p&gt;A friend was asking me for some SQL samples the other day so I dug up this old crib sheet from some time ago. These can be used with slight modification in both iSeries and .NET queries. Enjoy!&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Select Statements&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Return all records all columns in a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from MyTableq3 &lt;/p&gt;  &lt;p&gt;Return all records but only cqcus and cqcush in a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select cqcus, cqcush from MyTableq3 &lt;/p&gt;  &lt;p&gt;Return cqcus for all records in a table with a specific value for cqcush: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select cqcus from MyTableq3 where cqcush=123 &lt;/p&gt;  &lt;p&gt;Return all records in a table where cqcus is one of three possible values: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from MyTableq3 where cqcus in (value1,value2,value3) &lt;/p&gt;  &lt;p&gt;Return the number of records in a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select count(*) from TheTable &lt;/p&gt;  &lt;p&gt;Return the number of records in a table with a specific value for cqcush: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select count(*) from MyTableq3 where cqcush=123 &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Simple join:&lt;/strong&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from MyTableq3, MyTable    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where MyTableq3.cqcus=MyTable .cqcusA &lt;/p&gt;  &lt;p&gt;or &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select MyTableq3.cqcus, MyTable .cqcusA from MyTableq3, MyTable    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where MyTableq3.cqcush=MyTable .cqcusB &lt;/p&gt;  &lt;p&gt;Select all unique values in cqcus from a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select distinct(cqcus) from MyTableq3 &lt;/p&gt;  &lt;p&gt;or &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select distinct cqcus from MyTableq3 &lt;/p&gt;  &lt;p&gt;Select all unique values for cqcus from a table together with the number of records with that unique value: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select cqcus, count(*) from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; group by cqcus &lt;/p&gt;  &lt;p&gt;Select all unique values for combinations of cqcus and cqcush from a table together with the number of records with that combination: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select cqcus, cqcush, count(*) from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; group by cqcus, cqcush &lt;/p&gt;  &lt;p&gt;Select the number of unique values: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select count(distinct cqcus) from MyTableq3 &lt;/p&gt;  &lt;p&gt;Select all duplicate records in a table, where two (or more) records are considered duplicates if they share a common value for a single cqcus: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select cqcus, count(cqcus) from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; group by cqcus    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; having count(*) &amp;gt; 1 &lt;/p&gt;  &lt;p&gt;Select all duplicate records in a table, where two (or more) records are considered duplicates if they share common values for a pair of cqcuss: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select cqcus, cqcush, count(*) from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; group by cqcus, cqcush    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; having count(*) &amp;gt; 1 &lt;/p&gt;  &lt;p&gt;Select similar records, i.e. all records which have duplicate cqcus and cqcush in a table but with different cqcus3 (i.e. specifying which cqcuss must be the same and which different): &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from table as A, table as B   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where A.cqcus=B.cqcus    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; and A.cqcush=B.cqcush    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; and A.cqcus3&amp;lt;&amp;gt;B.cqcus3; &lt;/p&gt;  &lt;p&gt;Note: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; * It is important to specify at least one cqcus which is different between the two records otherwise this query will list a record as being the same as itself.   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; * This query will not find duplicate records, i.e. records with every cqcus the same. &lt;/p&gt;  &lt;p&gt;Select all records from a table which do not share a common ID with records from a second table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where cqcus not in (select cqcush from MyTable ) &lt;/p&gt;  &lt;p&gt;Note: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; * Sub-queries are quite slow.   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; . &lt;/p&gt;  &lt;p&gt;An alternative using a join (which can be much faster): &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select MyTableq3.* from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; left join MyTable&amp;#160; on (MyTableq3.cqcus = MyTable .cqcush)    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where MyTable .cqcush is null; &lt;/p&gt;  &lt;p&gt;The following method (which has been suggested by Michael Miller) is to use EXISTS. It is much faster on SQL Server than the above (but Michael says it is comparable with the left join technique on Oracle): &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where not exists (select cqcush from MyTable&amp;#160; where MyTable .cqcush = MyTableq3.cqcus) &lt;/p&gt;  &lt;p&gt;To perform a two way join: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; MyTableq3 left join MyTable&amp;#160; on (MyTableq3.cqcus = MyTable .cqcus),    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; MyTableq3 left join table3 on (MyTableq3.cqcush = table3.cqcus3) &lt;/p&gt;  &lt;p&gt;this has been tested on SQL Server, but not on Oracle or MySql. It does not work with MS-Access. &lt;/p&gt;  &lt;p&gt;To combine the results of two queries (be aware that the number and types of cqcuss in both queries must agree): &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * from MyTableq3   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; union select * from MyTable &lt;/p&gt;  &lt;p&gt;To return a value based on the contents of a cqcus. This can be done using either Iif, Decode or Case, depending on the database. &lt;/p&gt;  &lt;p&gt;The following works with MSAccess: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select Iif(cqcus = 1, 'one', 'not one')   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; from MyTableq3 &lt;/p&gt;  &lt;p&gt;This is equivalent to the following on SqlServer: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select Case when cqcus = 1 then 'One' else 'Two' End &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; from MyTableq3 &lt;/p&gt;  &lt;p&gt;Direct join to see if any records from table 1 match table 2   &lt;br /&gt;SELECT statement run complete.&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160; select * from MyTableq3, MyTable&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where cqcus=cfcus and&amp;#160; cqcush=cfcush     &lt;br /&gt; and cqvar = cfvar&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt; and cqlv = cflv&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;br /&gt; and cqsizgrp = cfsizgrp&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;For Oracle use the DECODE function. &lt;/p&gt;  &lt;p&gt;To create a new table to hold the results of the select query: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; select * into MyTable&amp;#160; from MyTableq3 &lt;/p&gt;  &lt;p&gt;Be aware that this will fail if MyTable&amp;#160; exists, and that the new table will be created without any indexes.   &lt;br /&gt;Insert &lt;/p&gt;  &lt;p&gt;Insert new record into a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; insert into MyTableq3 values (1,2,3) &lt;/p&gt;  &lt;p&gt;Insert new record into a table explicitly naming cqcuss: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; insert into MyTableq3 (cqcus,cqcush,cqcus3) values (1,2,3) &lt;/p&gt;  &lt;p&gt;Insert new record into a table using values from another table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; insert into MyTableq3 (cqcus,cqcush,cqcus3)   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; select cqcusA,2,cqcusC from SomeTable &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Update &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Update all records in a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; update MyTableq3 set cqcus=2 &lt;/p&gt;  &lt;p&gt;Update specific records in a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; update MyTableq3 set cqcus=2 where cqcus=1 &lt;/p&gt;  &lt;p&gt;To update more than one cqcus at a time: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; update MyTableq3 set cqcus=2, cqcush=3 &lt;/p&gt;  &lt;p&gt;Update a cqcus in a table using a value from another table where both records are referenced by a common key - warning, different databases support different syntax! &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; This works in MS-Access and MySQL (5) but not in SQL Server: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; update TableOne   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; inner join TableTwo on TableOne.commonID = TableTwo.commonID    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set TableOne.cqcus = TableTwo.cqcusX &lt;/p&gt;  &lt;p&gt;or &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; This works in MS-Access but not in SQL Server: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; update TableOne, TableTwo   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; set TableOne.cqcus = TableTwo.cqcusX    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; where TableOne.commonID = TableTwo.commonID &lt;/p&gt;  &lt;p&gt;or &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; update tableOne   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; set tableOne.cqcus=tableTwo.cqcusX    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; from tableOne, tableTwo    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; where tableOne.commonID=tableTwo.commonID &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Delete &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Delete all records in a table (dangerous): &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; delete from MyTableq3 &lt;/p&gt;  &lt;p&gt;Delete specific records in a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; delete from MyTableq3 where cqcus=value &lt;/p&gt;  &lt;p&gt;Delete records from one table which do not have a matching cqcus in another table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; delete from MyTableq3 where cqcus not in   &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; (select cqcush from TableTwo) &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Keys &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Be aware that there are often subtle syntax variations between different database systems. Also other key properties (for example 'clustered') will vary between database systems. Therefore please treat this part of the SQL crib sheet as a guide only. &lt;/p&gt;  &lt;p&gt;Create a primary key on a table: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; Alter Table TheTable Add Primary Key (cqcus, cqcush) &lt;/p&gt;  &lt;p&gt;To add an index on a cqcus: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; alter table MyTableq3 Add Index (cqcus) &lt;/p&gt;  &lt;p&gt;To remove a primary key: &lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; alter table drop primary key &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-4685009344255823477?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/06/sql-crib-sheet-for-iseries-and-net.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-5379290698216022266</guid><pubDate>Tue, 17 Jun 2008 13:17:00 +0000</pubDate><atom:updated>2008-07-31T06:18:44.881-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">opinion</category><category domain="http://www.blogger.com/atom/ns#">RPG vs C#</category><category domain="http://www.blogger.com/atom/ns#">iseres</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>C# -'The worst bloody language in the world'</title><description>&lt;p&gt;My brother-in-law, a Phd wielding university prof.who has a penchant for the complex and abstruse called around yesterday to declare the whole .Net&amp;#160; bouquet and the languages contained therein 'the worst bloody language in the world'.&amp;#160; He came to me asking some very simple questions such as how to read a customer file, display it in a windows form, process it etc and was soon bogged down in connection strings, data binding, data sets etc. &amp;quot;But I just want to display the data and read it!&amp;quot; he exclaimed. He was astounded that the columns in a table aren't easily directly accessible when using SQL which isn't checked until run-time (LINQ I suggest? &amp;quot; Yeah but you still have to go thru hoops!&amp;quot;).&amp;#160; &lt;br /&gt; Coming from procedural languages like RPG, I can sympathize. If I want to process a table in RPG&amp;#160; to check spending limits of a customer and update the table I do this&lt;/p&gt;  &lt;pre class="csharpcode"&gt;F CustomerFile IF   K DISK&lt;br /&gt;&lt;br /&gt;C  Read CustomerFile;&lt;br /&gt;C  DOW not %eof;&lt;br /&gt;C  If AmountSpent &amp;gt; CreditLimit;&lt;br /&gt;C  AllowSpending =False;&lt;br /&gt;C  Update CustomerFileR;   &lt;br /&gt;C  Endif;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;C  Read CustomerFile;&lt;br /&gt;C EndDO;&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The equivalent in C# is much more complicated and includes connection strings, command text and a data reader which all have to be set up. &lt;br /&gt;  &lt;br /&gt;Note that for the ONE 'F' declaration in RPG there are 3 in C#.&amp;#160; To even do a read needs to be setup - you need to create a data reader first. Imagine having to 'create' a read statement in RPG! The code doesn't even include the update functionality!&amp;#160; But the biggest problem is that column names are not typed directly in C# meaning you can't refer to the column name directly. The column 'AmountSpent' is not known to the C# program.&amp;#160;&amp;#160; Linq alleviates this situation but you still have to do the setup work first.&amp;#160; I understand the frustration. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; IBM.Data.DB2.iSeries;&lt;br /&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; iSeriesADOexample&lt;br /&gt;{&lt;br /&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;br /&gt;    {&lt;br /&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;br /&gt;        {&lt;br /&gt;            iDB2Connection connection = &lt;br /&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; iDB2Connection(&lt;span class="str"&gt;&amp;quot;DataSource=PUB1.RZKH.DE; UserID=XXX; Password=xxx; DefaultCollection=COLMBYRNE1; LibraryList=COLMBYRNE1, *USRLIBL&amp;quot;&lt;/span&gt;);&lt;br /&gt;            iDB2Command cmd = connection.CreateCommand();&lt;br /&gt;            connection.Open();&lt;br /&gt;            &lt;br /&gt;            cmd.CommandText = &lt;span class="str"&gt;&amp;quot;Select * from COLMBYRNE1.CUSTOMERFILE&amp;quot;&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;br /&gt;            {&lt;br /&gt;                iDB2DataReader dataReader = cmd.ExecuteReader();&lt;br /&gt;                &lt;span class="kwrd"&gt;while&lt;/span&gt; (dataReader.Read() == &lt;span class="kwrd"&gt;true&lt;/span&gt;)&lt;br /&gt;                {&lt;br /&gt;&lt;br /&gt;                   Double AmountSpent =  dataReader.GetDouble(3);&lt;br /&gt;                    Double CreditLimit = dataReader.GetDouble(4);&lt;br /&gt;&lt;br /&gt;                    &lt;span class="kwrd"&gt;if&lt;/span&gt; (AmountSpent &amp;gt; CreditLimit)&lt;br /&gt;                    {&lt;br /&gt;                        DoUpdate();&lt;br /&gt;                    }&lt;br /&gt;&lt;br /&gt;                        }&lt;br /&gt;                }&lt;br /&gt;                &lt;span class="kwrd"&gt;catch&lt;/span&gt; (iDB2SQLErrorException e)&lt;br /&gt;            {Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Error:&amp;quot;&lt;/span&gt; + e.MessageDetails);&lt;br /&gt;                }&lt;br /&gt;            Console.Read();&lt;br /&gt;            cmd.Dispose();&lt;br /&gt;        }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    &lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Programming is the art of bringing ideas to life. That's what my brother-in-law came to me for. He had an idea for a program and wanted to make it real. Unfortunately the initial&amp;#160; hurdle to create his simple program was far too great. The wizard functionality in Visual Studio only highlights how difficult it is to do basic actions like read a table, display the contents, process the results and update the table. This is one of the most common programs that every programmer creates yet in .NET it is difficult for a beginner. &lt;br /&gt;  &lt;br /&gt;It is clear Microsoft have 5-10 years to go before .NET is really mature and allows both beginner and seasoned developer to easily bring their ideas into the world. We program to make things better, faster, more fun, more interesting - not harder.&amp;#160; The tools we use then should also be better, faster - not harder. &lt;strong&gt;The effort to use a tool must never be greater than the effort it takes to solve the problem logically.&lt;/strong&gt;&amp;#160; (&lt;em&gt;Byrne's first hypothesis*&lt;/em&gt;) If you want to add 2 and 5 , C# should do that as easily as it does to solve it- and it does&amp;#160; &lt;em&gt;int sum = 2+ 5;&lt;/em&gt;&amp;#160;&amp;#160;&amp;#160; E.g. if a client says that some of his customers are over their credit limit and needs to halt their spending then the logical solution which is to flag those spenders. The effort to implement that in C# should be that easy.&amp;#160; This is the benchmark which Microsoft must follow - just to keep up.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-5379290698216022266?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/06/c-worst-bloody-language-in-world.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">9</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-1934124314584897798</guid><pubDate>Mon, 05 May 2008 14:12:00 +0000</pubDate><atom:updated>2008-07-31T07:15:43.398-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseres</category><category domain="http://www.blogger.com/atom/ns#">db2 .net data provider</category><category domain="http://www.blogger.com/atom/ns#">as/400</category><category domain="http://www.blogger.com/atom/ns#">linq</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">ibm</category><category domain="http://www.blogger.com/atom/ns#">db2</category><title>LINQ to DB2 Beta available tomorrow</title><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As you probably know the geeks at IBM have been scrambling to put together a LINQ to DB2 Entity framework ever since LINQ was announced - and by jove they've done it!&amp;#160; &lt;br /&gt;You know what LINQ is right? It allows you to query data in C# and refer to columns in tables&amp;#160; by their column names directly just as you would any field in your C# program. Yes I know, this seems like an uber basic requirement for any language but at least it is done.     &lt;br /&gt;Initially LINQ had only SQL, XML and in-memory fields were supported but IBM, Oracle and MySQL quickly started getting in on the act to support their dbs.     &lt;br /&gt;We've learned here at Dot Net Fluke that IBM will announce tomorrow (May 6th) a beta of the LINQ to DB2 beta. We'll post the link when it comes available.     &lt;br /&gt;The bad news is that it is &lt;strong&gt;not yet available for the iSeries&lt;/strong&gt;. So we'll all just have to sit and wait!&lt;/p&gt;  &lt;p&gt;Update: Here's the announcement &lt;a href="http://www.ibm.com/developerworks/forums/thread.jspa?threadID=203893&amp;amp;tstart=0"&gt;IBM Announces LINQ to DB2 connector&lt;/a&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-1934124314584897798?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/05/linq-to-db2-beta-available-tomorrow.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-6434413666662704916</guid><pubDate>Sat, 12 Apr 2008 21:02:00 +0000</pubDate><atom:updated>2008-04-21T02:04:04.101-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">serial</category><category domain="http://www.blogger.com/atom/ns#">C#</category><title>.Net powering LED Screens</title><description>&lt;p&gt;A client asked me recently to build an auction application to manage several county fairs. No problem you'd think. But it also needed to drive an LED screen 12 feet long and 5 feet high. I went and had a look at the screen and it had a worn RS232 serial cable sticking out the back. I connected that up to my laptop with USB to Serial converter, opened up the manual and started hacking away. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/hollywoodsign/SAxYgBS4V1I/AAAAAAAAAKI/buTlQo5CZjc/s1600-h/mission_sign%5B3%5D.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="212" alt="mission_sign" src="http://lh3.ggpht.com/hollywoodsign/SAxYghS4V2I/AAAAAAAAAKQ/yyzzFkQBNDo/mission_sign_thumb%5B1%5D.jpg?imgmax=800" width="299" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Turns out the System.IO.Ports namespace had everything I needed. In a surprisingly short amount of time the LED lit up with auction data. Of course that was just the beginning - the application had to subscribe to different events and manage the board at the same time so that became a little tricky.&lt;/p&gt;  &lt;p&gt;The board I was using was from EDI inc, so if you have a different manufacturer then the codes sent to the board might well differ. &lt;/p&gt;  &lt;table cellspacing="0" cellpadding="2" width="400" border="1"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="400"&gt;         &lt;pre&gt;using System;&lt;br /&gt;using System.IO.Ports;&lt;br /&gt;using System.Threading;&lt;br /&gt;&lt;br /&gt;public class PortChat&lt;br /&gt;{&lt;br /&gt;    static bool _continue;&lt;br /&gt;    static SerialPort _serialPort;&lt;br /&gt;&lt;br /&gt;    public static void Main()&lt;br /&gt;    {&lt;br /&gt;        string name;&lt;br /&gt;        string message;&lt;br /&gt;        StringComparer stringComparer = StringComparer.OrdinalIgnoreCase;&lt;br /&gt;        Thread readThread = new Thread(Read);&lt;br /&gt;&lt;br /&gt;        // Create a new SerialPort object with default settings.&lt;br /&gt;        _serialPort = new SerialPort();&lt;br /&gt;&lt;br /&gt;        // Allow the user to set the appropriate properties.&lt;br /&gt;        _serialPort.PortName = &amp;quot;COM2&amp;quot;;&lt;br /&gt;        _serialPort.BaudRate = &amp;quot;1200&amp;quot;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;        &lt;pre&gt;        _serialPort.Parity = &amp;quot;0&amp;quot;&lt;br /&gt;        _serialPort.DataBits = &amp;quot;8&amp;quot;;&lt;br /&gt;        _serialPort.StopBits = &amp;quot;1&amp;quot;;&lt;br /&gt;             // Set the read/write timeouts&lt;br /&gt;        _serialPort.ReadTimeout = 500;&lt;br /&gt;        _serialPort.WriteTimeout = 500;&lt;br /&gt;&lt;br /&gt;        _serialPort.Open();&lt;br /&gt;        _continue = true;&lt;br /&gt;        readThread.Start();&lt;br /&gt;&lt;br /&gt;        Console.Write(&amp;quot;0x00 This writes to Line 1 0x00&amp;quot;);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;        &lt;pre&gt;          Console.Write(&amp;quot;0x01 This writes to Line 2 0x01&amp;quot;);&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;        &lt;pre&gt;       name = Console.ReadLine();&lt;/pre&gt;&lt;br /&gt;      &lt;/td&gt;&lt;br /&gt;    &lt;/tr&gt;&lt;br /&gt;  &lt;/tbody&gt;&lt;/table&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-6434413666662704916?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/04/net-powering-led-screens.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-4526212180869019680</guid><pubDate>Tue, 18 Mar 2008 16:26:00 +0000</pubDate><atom:updated>2008-03-18T09:28:06.400-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">ado.net</category><category domain="http://www.blogger.com/atom/ns#">as/400</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">db2</category><category domain="http://www.blogger.com/atom/ns#">RPG</category><title>C# Subfile - iSeries data in a C# Grid -2  no coding (with Video)</title><description>&lt;p&gt;Well almost no coding.&lt;/p&gt;  &lt;p&gt;If you look at my &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/03/c-subfile-display-iseries-table-in-grid.html" target="_blank"&gt;previous post&lt;/a&gt; where I showed how to code a grid in C# using data from the iSeries we manually coded the grid, the data set and the connection. This example accomplishes the same result except you'll be done in under 5 minutes!&amp;#160; It uses the IDE to build the grid, data set, adapter, connection and SQL command. &lt;/p&gt;  &lt;p&gt;The video also shows how to add in the iSeries .net data components to your Visual Studio toolbox.   &lt;br /&gt;This post easier shown than discussed - so check out the following &lt;a href="http://screencast.com/t/OOnb3wXcW" target="_blank"&gt;video&lt;/a&gt;.    &lt;br /&gt;&lt;a href="http://screencast.com/t/OOnb3wXcW" target="_blank"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="224" alt="play" src="http://lh4.google.com/hollywoodsign/R9_tTRLDPhI/AAAAAAAAAKA/0q_L_EgcOco/play%5B3%5D?imgmax=800" width="244" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Steps&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Create a windows form application project&lt;/li&gt;    &lt;li&gt;Add in the IBM dll to your references&lt;/li&gt;    &lt;li&gt;Add in the IBM data tools to your toolbox using Tools, Choose Toolbox items and filter 'idb2'&lt;/li&gt;    &lt;li&gt;Add a basic grid to your form &lt;/li&gt;    &lt;li&gt;Drag the iDB2Connection, IDB2Command, iDB2DataAdapter and a data set to your form&lt;/li&gt;    &lt;li&gt;Configure each by right clicking and selecting properties&lt;/li&gt;    &lt;li&gt;Double click outside the grid to bring up the code for the Load method of the form. &lt;/li&gt;    &lt;li&gt;Add in the following code      &lt;br /&gt;iDB2DataAdapter1.Fill(dataSet1);      &lt;br /&gt;dataGrid1.DataMember = dataSet1.Tables[0].TableName;&lt;/li&gt;    &lt;li&gt;Run the program!     &lt;br /&gt;&lt;/li&gt; &lt;/ol&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-4526212180869019680?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/03/c-subfile-iseries-data-in-c-grid-2-no.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-1063112937157568836</guid><pubDate>Tue, 18 Mar 2008 00:31:00 +0000</pubDate><atom:updated>2008-03-17T17:54:06.594-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">ado.net</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">dataset</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">RPG</category><title>C# Subfile - Display an iSeries table in a Grid</title><description>&lt;p&gt;We're all used to subfiles on the iSeries. Who can fondly recall many a debate over page by page vs. load all subfile?&amp;#160;&amp;#160; How do you create the equivalent of a subfile in .Net?&lt;/p&gt;  &lt;p&gt;Easy. &lt;/p&gt;  &lt;p&gt;&lt;img height="17" alt="images" src="http://lh4.google.com/hollywoodsign/R94UChLDPeI/AAAAAAAAAJo/_hFsAX9DURQ/images_thumb%5B2%5D?imgmax=800" width="26" align="left" border="0" /&gt;&lt;/p&gt;  &lt;p&gt;Download the visual studio project from &lt;a href="http://aranrock.dyndns.info/blog/code/iSeries%20Grid.zip" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.google.com/hollywoodsign/R98HURLDPfI/AAAAAAAAAJw/0if0LnBtLZw/subfile%5B2%5D?imgmax=800"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="244" alt="subfile" src="http://lh5.google.com/hollywoodsign/R98HUhLDPgI/AAAAAAAAAJ4/Xk87QIcGyIE/subfile_thumb?imgmax=800" width="178" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Here's a basic example to get started. The Visual Studio IDE can actually do a lot of the work for you. You can even create a grid (read subfile) with just one or two lines of code. (Post to come)&amp;#160; However, it's more prudent to begin with code you can understand rather than wading through what looks like &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/01/what-are-all-those-adapters-and.html" target="_blank"&gt;binary spaghetti&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;This example also introduces data sets and data tables. Data sets are just like data structures but without any definition and data tables are just like the field definitions of data structures -not to be confused with tables in databases. We use Data sets and data tables to disconnect from the data source. Connect to the data source, get the data, fill the data set with the data, disconnect from the data source and use the data set in lieu of the actual data. Another way to think of data sets is to think of them as a cache, bucket, container, plastic bag. See my earlier post on &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/01/datasets-are-what.html" target="_blank"&gt;data sets&lt;/a&gt; for more info.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Steps&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Define your grid (i.e. subfile) &lt;/li&gt;    &lt;li&gt;Attach the grid to your form (VS creates one for you auto-) &lt;/li&gt;    &lt;li&gt;Create a data set to hold your data &lt;/li&gt;    &lt;li&gt;Create a data table to define the fields in the data set &lt;/li&gt;    &lt;li&gt;Add the data table to the data set &lt;/li&gt;    &lt;li&gt;Connect&amp;#160; to your iSeries &lt;/li&gt;    &lt;li&gt;Execute an SQL statement to read from a table &lt;/li&gt;    &lt;li&gt;Read each row and add to the data set &lt;/li&gt;    &lt;li&gt;Disconnect from the iSeries &lt;/li&gt;    &lt;li&gt;Attach the data set to the grid &lt;/li&gt;    &lt;li&gt;Display the grid &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;It sounds like a lot of work just to output data to a grid - and it is. Why bother with the data set and the table - can't I just write directly out the grid? Yes you can - but this example is here to show you not only how to display data in a grid from the iSeries but how to best manage that data as well. A Data Set will help you do that.&amp;#160; &lt;br /&gt;It is true that there are much simpler approaches on the iSeries but that comes at a price. Once you get out of the db2 and green screen box things get quite tricky on the As/400.&amp;#160; .Net is more complicated yes but its complexity comes from flexibility.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;iSeries prerequisites:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The table on the iSeries in this example is called customers. Create it in library QGPL   &lt;br /&gt;create the table in DDS or go into SQL by typing 'strsql' in the iSeries command prompt and create the table as follows:&lt;/p&gt;  &lt;p&gt;CREATE TABLE QGPL/CUSTOMERS (NAME CHAR (30 ) NOT NULL WITH DEFAULT,    &lt;br /&gt;BALANCE DEC (5 ) NOT NULL WITH DEFAULT)&lt;/p&gt;  &lt;p&gt;Add records using the INSERT sql command, DBU or your favorite data editor on the iSeries&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;C# Code:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;This is the code for the form. The 'Program.cs' in solution explorer is unchanged. Simply create a windows project, double click on the form that appears and replace all the code with the code below. Insert your iSeries IP address and make sure you have created the iSeries table as describe above or replace with your own ensuring that you correctly specify the columns.&amp;#160;&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ComponentModel;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Data;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Drawing;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Windows.Forms;     &lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; IBM.Data.DB2.iSeries; &lt;span class="rem"&gt;// Make sure you add this under 'References' in Solution Explorer&lt;/span&gt;     &lt;br /&gt;&lt;span class="rem"&gt;// You need the above reference as a dll which is part of iSeries client access.&lt;/span&gt;     &lt;br /&gt;    &lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; iSeries_Grid     &lt;br /&gt;{     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;partial&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Form1 : Form     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="kwrd"&gt;public&lt;/span&gt; Form1()     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Form1_Load(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="rem"&gt;//Define the grid size&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DataGrid subfile = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataGrid();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; subfile.Location = &lt;span class="kwrd"&gt;new&lt;/span&gt; Point(0, 0);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; subfile.Size = &lt;span class="kwrd"&gt;new&lt;/span&gt; Size(400, 500);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="rem"&gt;//Attach it to the form&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Controls.AddRange(&lt;span class="kwrd"&gt;new&lt;/span&gt; Control[] { subfile });     &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="rem"&gt;// Create a DataSet to hold data from iSeries Table&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DataSet dataStructure = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataSet();     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="rem"&gt;//Create a table to hold the iSeries data&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; DataTable dt = &lt;span class="kwrd"&gt;new&lt;/span&gt; DataTable(&lt;span class="str"&gt;&amp;quot;Customers&amp;quot;&lt;/span&gt;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dt.Columns.Add(&lt;span class="str"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;);     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dt.Columns.Add(&lt;span class="str"&gt;&amp;quot;Balance&amp;quot;&lt;/span&gt;);     &lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="rem"&gt;//Add the datatable to the data set&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; dataStructure.Tables.Add(dt);     &lt;br /&gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class="rem"&gt;// Open connection to the iSeries&lt;/span&gt;     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; iDB2Connection conn = &lt;span class="kwrd"&gt;new&lt;/span&gt; iDB2Connection();     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; conn.ConnectionString = &lt;span class="str"&gt;&amp;quot;DataSource=192.168.0.1&amp;quot;&lt;/span&gt;;&lt;/p&gt;  &lt;pre class="csharpcode"&gt; &lt;span class="rem"&gt;// You can put &amp;quot;UserID=myuserid;Password=mypass&amp;quot; &lt;br /&gt;// &lt;/span&gt;&lt;span class="rem"&gt;if you don't want to be prompted&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;   //  &lt;span class="rem"&gt;Create a command to select records from the customer table&lt;/span&gt;&lt;br /&gt;            iDB2Command command = &lt;span class="kwrd"&gt;new&lt;/span&gt; iDB2Command();&lt;br /&gt;          command.CommandText = &lt;span class="str"&gt;&amp;quot;Select * from qgpl.customers&amp;quot;&lt;/span&gt;;&lt;br /&gt;         command.Connection = conn; &lt;br /&gt; &lt;span class="rem"&gt;// ties the command to the connection to the iSeries&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;         conn.Open();&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// Execute the sql statement. Get a Data Reader object &lt;/span&gt;&lt;br /&gt;            iDB2DataReader readFile = command.ExecuteReader();&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// Read each row from the table and output the results into the data set&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt; (readFile.Read())&lt;br /&gt;            {&lt;br /&gt;                &lt;span class="rem"&gt;// Create a row to hold data&lt;/span&gt;&lt;br /&gt;                DataRow datarow = dataStructure.Tables[&lt;span class="str"&gt;&amp;quot;customers&amp;quot;&lt;/span&gt;].NewRow();&lt;br /&gt;&lt;br /&gt;                datarow[&lt;span class="str"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;] = readFile.GetString(0);&lt;br /&gt;                datarow[&lt;span class="str"&gt;&amp;quot;Balance&amp;quot;&lt;/span&gt;] = readFile.GetiDB2Integer(1);&lt;br /&gt;                &lt;br /&gt;                &lt;span class="rem"&gt;// add the row to the data table customer&lt;/span&gt;&lt;br /&gt;                dataStructure.Tables[&lt;span class="str"&gt;&amp;quot;customers&amp;quot;&lt;/span&gt;].Rows.Add(datarow);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                }       &lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// Clean up - Close connections&lt;/span&gt;&lt;br /&gt;            readFile.Close();&lt;br /&gt;            command.Dispose();&lt;br /&gt;            conn.Close();&lt;br /&gt;&lt;br /&gt;         &lt;span class="rem"&gt;//   Attach the data set to the data grid&lt;/span&gt;&lt;br /&gt;            subfile.DataSource = dataStructure;&lt;br /&gt;            subfile.DataMember = dataStructure.Tables[0].TableName;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;            &lt;span class="rem"&gt;// Display the subfile&lt;/span&gt;&lt;br /&gt;            subfile.Show();&lt;br /&gt;      &lt;br /&gt;&lt;br /&gt;        } &lt;span class="rem"&gt;// End of Method&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    } &lt;span class="rem"&gt;//End of Class&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;} // End of Namespace&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&amp;#160;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This code is based on an example in the IBM .Net Redbook modified &lt;br /&gt;  &lt;br /&gt;for this post.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-1063112937157568836?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/03/c-subfile-display-iseries-table-in-grid.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-730582020256822679</guid><pubDate>Mon, 17 Mar 2008 06:47:00 +0000</pubDate><atom:updated>2008-03-16T23:54:51.344-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">iseres</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">RPG</category><title>Reading an iSeries table in C# (with video)</title><description>&lt;p&gt;Here's another simple example of reading a table in C# from the iSeries.   &lt;br /&gt;&lt;a href="http://lh5.google.com/hollywoodsign/R94UAxLDPbI/AAAAAAAAAJQ/j-BK8omUI_Q/vid%5B5%5D?imgmax=800"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="20" alt="vid" src="http://lh4.google.com/hollywoodsign/R94UBhLDPcI/AAAAAAAAAJY/QXRp62e3hHo/vid_thumb%5B3%5D?imgmax=800" width="24" align="left" border="0" /&gt;&lt;/a&gt;&amp;#160; See the video for this &lt;a href="http://screencast.com/t/7wOw3HzfIH5" target="_blank"&gt;here.&lt;/a&gt;&amp;#160; &lt;a href="http://lh6.google.com/hollywoodsign/R94UCBLDPdI/AAAAAAAAAJg/udLSdNSukf4/images%5B4%5D?imgmax=800"&gt;&lt;/a&gt;    &lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="17" alt="images" src="http://lh4.google.com/hollywoodsign/R94UChLDPeI/AAAAAAAAAJo/_hFsAX9DURQ/images_thumb%5B2%5D?imgmax=800" width="26" align="left" border="0" /&gt;&lt;/p&gt;&amp;#160;&amp;#160; Download the Visual Studio Project &lt;a href="http://aranrock.dyndns.info/blog/code/readiSeriestable.zip" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;As you can see (line 13)&amp;#160; all you need in the connection string is the IP address of your machine. If you don't include the log on parameters -UserID=myuser; Password=mypass, then you will be prompted for them by the iSeries.    &lt;br /&gt;You need to include the IBM .net provider in your 'References' in your Visual Studio project. It's located in the Client Access directory. If you don't have client access, then download the 'technology preview' from IBM for free. &lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; IBM.Data.DB2.iSeries;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Prez_Rank&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;{&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    &lt;span class="kwrd"&gt;class&lt;/span&gt; Program&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            iDB2Connection conn = &lt;span class="kwrd"&gt;new&lt;/span&gt; iDB2Connection();&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;            conn.ConnectionString = &lt;span class="str"&gt;&amp;quot;DataSource=192.168.0.1&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;            conn.Open();&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            iDB2Command cmd = &lt;span class="kwrd"&gt;new&lt;/span&gt; iDB2Command();&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            cmd.CommandText = &lt;span class="str"&gt;&amp;quot;Select * from colm.customers&amp;quot;&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;            cmd.Connection = conn;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;            iDB2DataReader dr= cmd.ExecuteReader();&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            &lt;span class="kwrd"&gt;while&lt;/span&gt; (dr.Read())&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;                Console.WriteLine(dr.GetString(0));&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;            Console.ReadLine();&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;  &lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-730582020256822679?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/03/reading-iseries-table-in-c-with-video.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-1405872447442578074</guid><pubDate>Thu, 06 Mar 2008 07:48:00 +0000</pubDate><atom:updated>2008-03-18T00:49:26.412-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">as/400</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">variables</category><title>RPG Variables vs C# Variables</title><description>&lt;p&gt;In RPG we define variables in our 'D or C Specs.&amp;#160; We don't have to&amp;#160; uniquely declare character or numeric-&amp;#160; just the inclusion of a value in the decimal places column is enough. Leave it out and you just defined a character variable.    &lt;br /&gt;For the most part this is all you need to write 90% of business applications. There are other variable types such Binary, Graphic etc but these are encountered less often.    &lt;br /&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;font face="Courier" size="2"&gt;DName+++++++++++ETDsFrom+++To/L+++IDc.Keywords++&lt;/font&gt;&lt;/p&gt;  &lt;pre class="csharpcode"&gt;D NameofDog       S             24              &lt;br /&gt;D Counter         S              2  0  &lt;br /&gt;D  Price          S              5  2           &lt;br /&gt;D Datefield       S               D             &lt;br /&gt;&lt;br /&gt;Here's the equivalent in C#&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;String NameofDog;&lt;br /&gt;&lt;span class="kwrd"&gt;int&lt;/span&gt; Counter;&lt;br /&gt;&lt;span class="kwrd"&gt;decimal&lt;/span&gt; Price;&lt;br /&gt;DateTime datefield;&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The first thing that you will notice is that there is no length defined for the fields in C#. That's a great improvement over RPG where you usually explicitly declare length and end up in lots of trouble when a value gets chopped off when moved to a smaller field.&lt;br /&gt;  &lt;br /&gt;In C# there are way more value types than needed such as byte (for numbers 0-255), sbyte, short, long, float etc. &lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;Common Value Types in C#&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;Int - integer - whole numbers (no decimals). Useful for counting.&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;string - holds alphanumeric values&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;bool - true or false (similar to indicators)&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;double any decimal up to 15 significant digits&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;decimal - any decimal up to 28 sig. digits&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The variable declarations in RPG did not quite translate to C#. There is no Date value type in C#.&amp;#160; The statement '&lt;em&gt; &lt;/em&gt;DateTime datefield;' declares an object reference called datefield. How do I know this? Only because I know there is not value type of date in C#.&amp;#160; The fact that I am declaring an object called datefield just as I would a variable value brings up all sorts of interesting things about C# - mainly that objects are just another kind of variable. More on that later.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;What about Operations on variables?&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;Let's add 1 to Counter in RPG and C#&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;RPG&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;Counter = Counter + 1;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;C#&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;Counter = Counter + 1;&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The code is the exact same in both!&amp;#160; There are other differences but we'll get operations in another post.&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;strong&gt;Lot's of free stuff inside&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;When you declare a variable in C# whether it is a value type like an integer or a 'reference' type like the DateTime object I created, along with the variable comes packaged&amp;#160; actions you might need on it.&amp;#160; In RPG if I want to convert my counter to a string variable, I would do the following.&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;RPG&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;font face="Courier"&gt;Character = %&lt;span class="kwrd"&gt;char&lt;/span&gt;(Numeric);&lt;/font&gt;&amp;#160; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;In C#, there is a method or function included in the variable when you declare it. The brackets indicate that ToString is a method.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;Character = Numeric.ToString();&lt;/pre&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt;	font-size: small;&lt;br /&gt;	color: black;&lt;br /&gt;	font-family: consolas, "Courier New", courier, monospace;&lt;br /&gt;	background-color: #ffffff;&lt;br /&gt;	/*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt;	background-color: #f4f4f4;&lt;br /&gt;	width: 100%;&lt;br /&gt;	margin: 0em;&lt;br /&gt;}&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This is a fundamental and important aspect of C# - The actions you perform on variables and objects are often methods of that variable or object. If you want to trim the end of a string in C# you just say Character.Trim(); . Because you declared Character as a type String and String has all these methods now Character has them. There is no 'trim' opcode or expression. It's a method of string and when you declare a variable as a type string it gets all the methods belonging to string.&lt;br /&gt;  &lt;br /&gt;What's great about this is that you don't have to wait 10 years for IBM to come up with another op-code - you just write one yourself!&amp;#160; But, you may be asking, how do I know what method to use? There must be thousands. There are. However the Visual Studio IDE makes it simple and has a feature called intellisense - it fills out the statement as you type showing a drop down of all the methods and properties of an object or variable. Don't worry if this doesn't make a huge amount of sense right now. You'll get the hang of it with practice but it is one of those kind of mind-flips that is a big switch from Procedural RPG and Object Oriented C#.&amp;#160; It also makes sense. While RPG is an awesome language it has hit a stone wall. Creating lots of more opcodes or expressions is just going to make the language more complex. C# doesn't need lots of 'op-codes' - in fact there are about 77 in C# 2.0 and many you will never use. Most actions come from methods in classes.&lt;br /&gt;&lt;br /&gt;  &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-1405872447442578074?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/03/rpg-variables-vs-c-variables.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-2967298640652638398</guid><pubDate>Tue, 12 Feb 2008 06:47:00 +0000</pubDate><atom:updated>2008-02-18T12:53:34.182-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">loops</category><category domain="http://www.blogger.com/atom/ns#">c sharp</category><category domain="http://www.blogger.com/atom/ns#">iterations; structured operations;</category><title>Comparing Loops in RPG and C#</title><description>&lt;p&gt;Looping operations are quite similar in C# and RPG. Note that RPG uses 'EndDo' or 'EndFor' and C# uses curly braces {} as the beginning and end of a loop (or any code block for that matter).&lt;/p&gt; &lt;p&gt;Here's the different loops &lt;br&gt;A = 0; B=10 &lt;br&gt;&lt;em&gt;'Statements'&lt;/em&gt; is all the code in the loop that you wish to iterate over.&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="405" border="2"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="226"&gt;&lt;strong&gt;&lt;font color="#008040"&gt;RPG Loop&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt; &lt;td valign="top" width="175"&gt;&lt;strong&gt;&lt;font color="#008040"&gt;C# Loop&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="226"&gt;DOW (A&amp;lt;b); &lt;em&gt;statements&lt;/em&gt; EndDo;&lt;/td&gt; &lt;td valign="top" width="175"&gt;While (a &amp;lt;b)&amp;nbsp; {&lt;em&gt;statements&lt;/em&gt;}&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="226"&gt;FOR A = 1 to 10;&amp;nbsp; &lt;em&gt;statements&lt;/em&gt;&amp;nbsp; EndFor;&lt;/td&gt; &lt;td valign="top" width="175"&gt;For (int a=0; a&amp;lt;10; a++)&amp;nbsp; {&lt;em&gt;statements&lt;/em&gt;}&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="226"&gt;DOU A &amp;gt; B; &lt;em&gt;statements&lt;/em&gt;&amp;nbsp; EndDo;&lt;/td&gt; &lt;td valign="top" width="175"&gt;Do&amp;nbsp;&amp;nbsp; {&lt;em&gt;statements&lt;/em&gt;} &lt;br&gt;while (A &amp;gt;B);&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="226"&gt;&amp;nbsp;&lt;/td&gt; &lt;td valign="top" width="175"&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Both languages have ways to skip statements or break out of the loop&lt;/p&gt; &lt;table cellspacing="0" cellpadding="2" width="400" border="2"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td valign="top" width="224"&gt;iter;&lt;/td&gt; &lt;td valign="top" width="173"&gt;Continue;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" width="224"&gt;Leave;&lt;/td&gt; &lt;td valign="top" width="173"&gt;break;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Here's sample code showing the C# while loop (same as RPG DOW) &lt;br&gt;Note that the While operation code has {} braces to denote the beginning and end of the loop.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The Do While loop...&lt;/strong&gt;&lt;/p&gt;&lt;pre class="code"&gt;            &lt;span style="color: green"&gt;// The while loop&lt;br /&gt;            // The while statement is equivalent to the RPG 'DOW'&lt;br /&gt;            &lt;/span&gt;&lt;span style="color: blue"&gt;int &lt;/span&gt;ebayJunk = 0;&lt;br /&gt;            &lt;span style="color: blue"&gt;int &lt;/span&gt;CreditLeft = 500;&lt;br /&gt;            &lt;span style="color: blue"&gt;bool &lt;/span&gt;HaveMoney = &lt;span style="color: blue"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre class="code"&gt;// The loop will execute as long as HaveMoney is true;&lt;br /&gt;            &lt;span style="color: blue"&gt;while &lt;/span&gt;(HaveMoney) // checks before going into the loop&lt;br /&gt;            { // beginning of while loop&lt;br /&gt;                ebayJunk += 1;&lt;br /&gt;                CreditLeft -= 100;&lt;br /&gt;                &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Useless Gadgets={0}"&lt;/span&gt;, ebayJunk);&lt;br /&gt;                &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Money left=${0}"&lt;/span&gt;, CreditLeft);&lt;br /&gt;&lt;br /&gt;        &lt;span style="color: blue"&gt;if &lt;/span&gt;(CreditLeft &amp;lt;= 0) { HaveMoney = &lt;span style="color: blue"&gt;false&lt;/span&gt;; } &lt;span style="color: green"&gt;// Set condition for while loop&lt;br /&gt;                // Entire loop is executed a&lt;br /&gt;            &lt;/span&gt;} // end of while loop (same as EndDO in RPG &lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"You're Broke!!"&lt;/span&gt;);&lt;br /&gt;            &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.ReadLine();&lt;br /&gt;    &lt;/pre&gt;&lt;pre class="code"&gt;&lt;strong&gt;And the For loop....&lt;/strong&gt;&lt;/pre&gt;&lt;pre class="code"&gt;&lt;span style="color: green"&gt;// For loop example. Finds the first blank space in a string&lt;br&gt;&lt;/span&gt;&lt;span style="color: green"&gt;// The block of code between the curly braces gets iterated&lt;br&gt;// over. The loop decrements from the length&lt;/span&gt;&lt;span style="color: green"&gt;&lt;/pre&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="color: #2b91af"&gt;String &lt;/span&gt;field = &lt;span style="color: #a31515"&gt;"To the Galaxy and Beyond"&lt;/span&gt;;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;&lt;span style="color: blue"&gt;for&lt;/span&gt;(&lt;span style="color: blue"&gt;int &lt;/span&gt;i = field.Length; i &amp;gt; 0; i--)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;{&lt;br /&gt;    &lt;span style="color: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="color: #a31515"&gt;"Letter is not blank: "&lt;/span&gt;+ field[i - 1]);&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;    &lt;span style="color: blue"&gt;if&lt;/span&gt;(field[i - 1] == &lt;span style="color: #a31515"&gt;' '&lt;/span&gt;)&amp;nbsp;&amp;nbsp; // note how I can treat a string like an array &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue"&gt;break&lt;/span&gt;; // exit once I reach a blank space&lt;/p&gt;&lt;br /&gt;&lt;p&gt;}&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;span class="sbmLink"&gt;&amp;nbsp;&lt;/p&gt;&lt;br /&gt;&lt;table cellspacing="1" cellpadding="1"&gt;&lt;br /&gt;&lt;tbody&gt;&lt;br /&gt;&lt;tr&gt;&lt;br /&gt;&lt;td class="sbmText"&gt;Share this post : &lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to del.icio.us" onmouseout="mOut(this)" href="http://del.icio.us/post?url=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/deliciou4.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to digg" onmouseout="mOut(this)" href="http://digg.com/submit?phase=2&amp;amp;url=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/digg14.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to dotnetkicks" onmouseout="mOut(this)" href="http://www.dotnetkicks.com/kick/?url=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/CropperCapture154.jpg" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to furl" onmouseout="mOut(this)" href="http://www.furl.net/store?s=f&amp;amp;to=0&amp;amp;u=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;ti=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/furl4.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to live" onmouseout="mOut(this)" href="https://favorites.live.com/quickadd.aspx?marklet=1&amp;amp;mkt=en-us&amp;amp;url=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/live4.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to reddit!" onmouseout="mOut(this)" href="http://reddit.com/submit?url=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/reddit4.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to spurl" onmouseout="mOut(this)" href="http://www.spurl.net/spurl.php?v=3&amp;amp;url=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/spurl8.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to technorati!" onmouseout="mOut(this)" href="http://technorati.com/faves/?add=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;title=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/technora4.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;br /&gt;&lt;td class="sbmDim" onmouseover="mOvr(this)" onmouseout="mOut(this)"&gt;&lt;a class="sbmDim" onmouseover="mOvr(this)" title="Post it to yahoo!" onmouseout="mOut(this)" href="http://myweb.yahoo.com/myresults/bookmarklet?u=http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html&amp;amp;t=Loops in C# and iSeries RPG comparison" target="_blank"&gt;&lt;img src="http://blogs.msdn.com/blogfiles/rahulso/WindowsLiveWriter/IconsfordifferentSocialBookmarkingSites_B387/yahoo9.png" border="0"&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/span&gt;&lt;pre class="code"&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-2967298640652638398?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/comparing-loops-in-rpg-and-c.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-6576330958349767811</guid><pubDate>Thu, 07 Feb 2008 23:22:00 +0000</pubDate><atom:updated>2008-02-17T16:47:56.435-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">parse method</category><category domain="http://www.blogger.com/atom/ns#">C#</category><category domain="http://www.blogger.com/atom/ns#">date conversion</category><category domain="http://www.blogger.com/atom/ns#">date</category><category domain="http://www.blogger.com/atom/ns#">parseexact</category><category domain="http://www.blogger.com/atom/ns#">RPG</category><title>Converting from a numeric date to a date type in C# and RPG</title><description>Let's compare one of the most common and confusing tasks for all programmers - date conversion.&lt;br /&gt;Given that this is such as a common programming task I am always surprised by how complex this is in many languages.&lt;br /&gt;Here's our problem. Our iSeries legacy table 'Orders' is holding its order date not in the iSeries Date type but in numeric 8,0 in ISO format YYYYMMDD. e.g. ORDATE = 20081021&lt;br /&gt;We need to convert this to a date type in RPG so that we can do some date work - adding a day on it subtracting order date from ship date etc.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RPG Code&lt;/strong&gt;&lt;br /&gt;Line 1 is the D-spec entry to define the converted date.&lt;br /&gt;Line 2 defines the input order date (typically this comes from a db)&lt;br /&gt;&lt;br /&gt;&lt;span style="color:#009900;"&gt;D OrderDateD S d datfmt(*iso)&lt;br /&gt;D ORDATE S 8 0&lt;br /&gt;OrderDateD = %date(ORDATE:*ISO);&lt;br /&gt;// now we cand do some date work with OrderDateD!&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now lets do the same thing in C#&lt;br /&gt;&lt;strong&gt;C# Code&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;/pre&gt;&lt;span style="color:#009900;"&gt;Console.WriteLine("Method 2 - ParseExact Method a little simpler");&lt;br /&gt;int ORDATE = 20081210;&lt;br /&gt;DateTime OrderDateD = DateTime.ParseExact(ORDATE.ToString(), "yyyyMMdd", System.Globalization.CultureInfo.InvariantCulture);&lt;br /&gt;Console.WriteLine("Date as numeric entered YYYYYMMDD {0}", OrderDateD);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;In C# you use the ParseExact method to convert from YYYYMMDD or any other format.&lt;br /&gt;1. Create a date type OderDate with the statement 'DateTime OrderDateD'&lt;br /&gt;2. Assign it the value of ORDATE after parsing it first&lt;br /&gt;&lt;br /&gt;The ParseExact method takes 3 parameters&lt;br /&gt;a) The input date in whatever format but converted to a string. We use ToString to convert&lt;br /&gt;b) The fomat of the input date which is specified here as YYYYMMDD. Click here for &lt;a href="http://aranrock.dyndns.info/blog/csharpdateformats.html"&gt;formats&lt;/a&gt;&lt;br /&gt;c) The 'invariant' culture property to tell the method that this is a non standard format. How geeky!&lt;br /&gt;&lt;br /&gt;There is another method called 'Parse' but ParseExact is used here because you can specify (in the second parm) the EXACT format that may not confom to any particular standard. This is really handy for handling obscue legacy stored dates in old iSeries tables.&lt;br /&gt;The Parse method though is really clever so when you are using standard date formats it can automatically figue out your date format without telling it what format you are using.&lt;br /&gt;&lt;br /&gt;I think its fair to say that the RPG approach is simpler and easier to understand. However there is more flexibility in the C# approach.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;DOWNLOADS&lt;/strong&gt;&lt;br /&gt;See the C# &lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/code/datecon.rar"&gt;code &lt;/a&gt;as a full project which shows both Parse and ParseExact&lt;br /&gt;Also here's an&lt;a href="http://www.aranrock.com/C_sharp_for_RPG_Programmers/code/rpgdates.txt"&gt; RPG date cheat sheet code &lt;/a&gt;adapated from a post by Mitchel Laman&lt;br /&gt;Which fomats to use when describing your input? Click &lt;a href="http://aranrock.dyndns.info/blog/csharpdateformats.html"&gt;here&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-6576330958349767811?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/converting-from-numeric-date-to-date.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-5933944810663266811</guid><pubDate>Fri, 01 Feb 2008 22:36:00 +0000</pubDate><atom:updated>2008-02-01T14:54:33.323-08:00</atom:updated><title>Getting data off the iSeries part 2</title><description>Someone asked me to expand on the Data Access overview from .NET I gave previously.&lt;br /&gt;If you want more information on this, go to the Programmer's Toolkit included with IBM's client access. It has excellent information with sample code.&lt;br /&gt;Here's an overview from the Programmer's Toolkit :&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;.NET Framework Classes - The Managed Provider&lt;/strong&gt;&lt;br /&gt;If you are using the .NET framework to connect to the iseries use the  IBM.Data.DB2.iSeries database provider for application development.  This is in c:/program files/IBM/Client Access/  as a dll. This managed provider will provide better performance than using the System.Data.OleDb provider to bridge to the iSeries Access OLE DB provider, or using the Microsoft.Data.Odbc provider to bridge to the iSeries Access ODBC driver.&lt;br /&gt;&lt;br /&gt;IBM.Data.DB2.iSeries database provider aka Managed Provider aka  IBM DB2 UDB for iSeries .NET Provider.  They all refer to the same integrated iSeries Access for processing DB2 using ADO.NET. &lt;br /&gt;These are the interfaces supported&lt;br /&gt;Provider Class Name             Interface(s) supported&lt;br /&gt;iDB2Connection                       DbConnection&lt;br /&gt;iDB2Command                         DbCommand&lt;br /&gt;iDB2DataReader                      DataReader; IDataRecord&lt;br /&gt;iDB2DataAdapter                    DbDataAdapter (inherits from IDataAdapter)&lt;br /&gt;iDB2Parameter                        DataParameter; IDbDataParameter&lt;br /&gt;iDB2ParameterCollection       IDataParameterCollection&lt;br /&gt;iDB2Transaction                       DbTransaction&lt;br /&gt;iDB2DbType                             iSeries-specific types&lt;br /&gt;iDB2Error                                  iSeries-specific errors&lt;br /&gt;iDB2ErrorCollection                 Collection, IEnumerable&lt;br /&gt;iDB2Exception                          Provider-specific exceptions&lt;br /&gt;iDB2CommandBuilder             iSeries-specific command builder&lt;br /&gt;advantages&lt;br /&gt;&lt;br /&gt;&lt;em&gt;advantages&lt;/em&gt;&lt;br /&gt;Easy to program&lt;br /&gt;Allows easy integration of SQL commands and result data with other data sources&lt;br /&gt;Application processes SQL commands directly into an ADO.NET DataSet object&lt;br /&gt;Application places SQL result data into an ADO.NET DataSet object&lt;br /&gt;Provides a minimal set of interfaces between the application and the iSeries database&lt;br /&gt;Increases performance without sacrificing functionality&lt;br /&gt;&lt;br /&gt;&lt;em&gt;disadvantage&lt;/em&gt;&lt;br /&gt;Record level access, program calls, and data queues are not supported.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ADO/OLE DB&lt;/strong&gt;&lt;br /&gt;The IBMDA400 and IBMDASQL providers allow you to send remote SQL statements to the iSeries server.  There is support for calling most SQL statements on the iSeries server.&lt;br /&gt;  The OLE DB provider record-level access support provides the ability to do the following:&lt;br /&gt;&lt;br /&gt;- open logical or physical files&lt;br /&gt;  - access records sequentially or by key&lt;br /&gt;  - read, insert, update, and delete records&lt;br /&gt;  - perform commitment control&lt;br /&gt;  - work with multiple file members&lt;br /&gt;  - work with multiple record formats&lt;br /&gt;&lt;br /&gt;&lt;em&gt;advantages&lt;/em&gt;&lt;br /&gt;Easy to program to.&lt;br /&gt;Provides SQL access and record-level access to database files.&lt;br /&gt;Excellent record level access performance.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;disadvantages&lt;/em&gt;&lt;br /&gt;Limited application optimization potential due to standard interface.&lt;br /&gt;Limited support for native DB2 UDB functions.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;ActiveX automation objects&lt;/strong&gt;&lt;br /&gt;The iSeries Access for Windows ActiveX automation object library provides a set of automation objects to allow easy access to iSeries host systems, data queues, programs and commands and call RPG programs.&lt;br /&gt;This is the CWBX.DLL library that you need to add to solution explorer.&lt;br /&gt;&lt;br /&gt;   - accessing iSeries data queues&lt;br /&gt;   - calling iSeries server APIs and user programs&lt;br /&gt;   - managing connections and validating security&lt;br /&gt;   - running CL commands on the iSeries server&lt;br /&gt;   - performing data type and code page conversions&lt;br /&gt;   - transferring database data to and from the iSeries server&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;em&gt;advantages&lt;/em&gt;&lt;br /&gt;Easy to program to.&lt;br /&gt;Automatic conversion to and from many popular PC file formats.&lt;br /&gt;Provides high-level object for easiest data transfers and low-level objects for customized data transfers.&lt;br /&gt;Supports creating, modifying, saving, and executing data transfer request files.&lt;br /&gt;Request files are interchangeable with the Data Transfer GUI and batch applications.&lt;br /&gt;&lt;br /&gt;&lt;em&gt;disadvantages&lt;/em&gt;&lt;br /&gt;The database SQL support is limited to SELECTs and full file updates.&lt;br /&gt;No support for record level access.&lt;br /&gt;Slower performance in performing individual file/individual row updates than OLE DB record level access.&lt;br /&gt;No future updates planned for this interface.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ODBCadvantagesApplications capable of accessing database files on servers other than iSeries (using non-iSeries Access for Windows ODBC driver) disadvantagesDifficult to program to, though easier than C API.Limited support for native DB2 UDB functions.&lt;br /&gt;  .&lt;br /&gt;The above is summarized from IBM's Programmer's toolkit documentation.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-5933944810663266811?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/02/getting-data-off-iseries-part-2.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-5752867610009374467.post-4650912974959973216</guid><pubDate>Sun, 27 Jan 2008 03:17:00 +0000</pubDate><atom:updated>2008-01-29T20:32:49.591-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">RPG vs C#</category><category domain="http://www.blogger.com/atom/ns#">iseries</category><category domain="http://www.blogger.com/atom/ns#">as/400</category><category domain="http://www.blogger.com/atom/ns#">.net</category><category domain="http://www.blogger.com/atom/ns#">method</category><category domain="http://www.blogger.com/atom/ns#">subroutine</category><category domain="http://www.blogger.com/atom/ns#">exsr</category><title>RPG Subroutine = C# Method?</title><description>Someone asked me the other day if RPG subroutines are the same as C# methods.&lt;br /&gt;The answer is yes - like C# static methods but RPG Procedures are even more similar to C# static methods.&lt;br /&gt;The reason being is that while C# methods are discrete named blocks of code you can call from within a program (C# Class) - just like an RPG Subroutine; C# methods allow parameters in the call - just like RPG procedures do. Methods have lots of other features that I’ll get in to but first lets draw comparisons.&lt;br /&gt;Here’s an example:&lt;br /&gt;Both applications read a table called ‘People’ and print out the name of each person on the console.&lt;br /&gt;They both call a subroutine/method called Get_People that takes no parameters from the main block of code.&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;RPG&lt;/strong&gt;&lt;br /&gt;Fpeople IF E K DISK&lt;br /&gt;/FREE&lt;br /&gt;exsr Get_People ;&lt;br /&gt;*inlr = *on;&lt;br /&gt;&lt;br /&gt;BegSr Get_People;&lt;br /&gt;read People ;&lt;br /&gt;dow not %eof ;&lt;br /&gt;Dsply name ;&lt;br /&gt;Read People&lt;br /&gt;Enddo;&lt;br /&gt;Endsr;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;C#&lt;/strong&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;pre class="csharpcode"&gt;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System.IO;&lt;br /&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; ConsoleApplication1&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; ProgramClass&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main() &lt;span class="rem"&gt;// Main block of code 'Main' must be in the class&lt;/span&gt;&lt;br /&gt;{&lt;br /&gt;get_People();&lt;br /&gt;}&lt;br /&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; get_People( )&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (FileStream fileStream = &lt;span class="kwrd"&gt;new&lt;/span&gt; FileStream(&lt;span class="str"&gt;@"C:\csharp\people.txt"&lt;/span&gt;,&lt;br /&gt;FileMode.Open,&lt;br /&gt;FileAccess.Read,&lt;br /&gt;FileShare.None))&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (StreamReader streamReader = &lt;span class="kwrd"&gt;new&lt;/span&gt; StreamReader(fileStream))&lt;br /&gt;{&lt;br /&gt;&lt;span class="kwrd"&gt;string&lt;/span&gt; text = streamReader.ReadLine();&lt;br /&gt;&lt;span class="kwrd"&gt;while&lt;/span&gt; (text != &lt;span class="kwrd"&gt;null&lt;/span&gt;)&lt;br /&gt;{&lt;br /&gt;Console.WriteLine(text);&lt;br /&gt;text = streamReader.ReadLine();&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;Console.ReadLine(); &lt;span class="rem"&gt;// Pause the screen&lt;/span&gt;&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;As you can see, RPG is easier to read and less verbose than its C# counterpart. To be fair DB2 is part of the iSeries operating system so all the file handling is already part of the DB.&lt;br /&gt;&lt;br /&gt;Remember these are Static methods shown in C#. A static method in C# is where there is only one instance of the method. Believe it or not you can multiple instances of a method in C#. These are called instance methods and are used more often than static methods. I'll get into the difference but the purpose of this post is to show some similarity between RPG and C# first.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5752867610009374467-4650912974959973216?l=www.aranrock.com%2FC_sharp_for_RPG_Programmers'/&gt;&lt;/div&gt;</description><link>http://www.aranrock.com/C_sharp_for_RPG_Programmers/2008/01/rpg-subroutine-c-method.html</link><author>noreply@blogger.com (Colm P O Byrne)</author><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total></item></channel></rss>
