/// Frank Hagen: Professional Web Developer, C# User, Reformed Über-geek RSS 2.0
# Monday, October 22, 2007

Bill Mauldin is probably the most famous cartoonist from World War II.  He was an infantry soldier in the Italian campaign who also worked for the Italian theaters version of Stars and Stripes, the soldier-run newspaper.  If you were to see one of his strips, you would immediately recognize his work.

The Brass Ring is Mauldin's autobiography of his early life through the end of WWII.  He tells of his very humble beginnings as the son of a poor farm family, life in the depression, and the start of his career as an illustrator.  He joined the National Guard at an early age at the encouragement of a close friend as it became evident that the Guard would be Federalized at the beginning of the war and before he could be drafted.  He was able to quickly establish himself as a journalist and cartoonist and so avoiding direct insertion into a combat unit.  This is the story of his experiences and the material he created from them.

The Brass Ring has a much more linear telling than Up Front and is easier to read because of it.  Again, I enjoyed the perspective of the infantryman in the trenches although Mauldin never really experienced combat as a reporter.  He seemed to be willing to put himself in the thick of it though, which is refreshing for a rear echelon type.  An enjoyable book, but not the collection of his work that I have been hoping for.  I will keep trying.

Monday, October 22, 2007 11:50:02 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Books
# Tuesday, October 16, 2007

I shouldn't be surprised, but I am:  A customer complained to me that the Flag field they wanted to indicate a Yes or No value was failing.  The Yes value was working fine, but No was being returned when they hadn't set anything yet.

I didn't realize that booleans were meant to represent Yes, No, and Maybe.  Silly Programmer, no bits for you.

Tuesday, October 16, 2007 10:43:53 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Worse Than Failure
# Tuesday, October 09, 2007

I am struggling with issues posting code samples in WordPress.  I am painfully aware that much of my code is cut off visually on the main page, and highlighting is spotty at best.  Suggestions for making it work in WordPress are appreciated.  I'd love to add an external stylesheet, but am loathe to pay for that add on.  An "extra" to handle it would be great, as long as it doesn't violate any EULAs.

Of course, WP layouts are pretty lacking too, without purchasing additional capabilities.  If I wanted to spend money doing this, I'd host this blog myself somewhere else and have Ultimate Freedom

I am working on it....

Update [10.08]:  I will be looking at Blogger and Blogsome to evaluate their engines for free coding blogs.  It is possible I may move again.  Also, I will renew my feedburner account so moves are more transparent; or completely so for RSS readers.

Tuesday, October 09, 2007 9:44:55 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Blog

This really should have been more obvious to me, so why did I have to look it up?  If you need to check for NULL in a returned field from SQL (or any other datasource), you should the .Equals method on System.DBNull.Value.  I usually prefer the "==" notation for conditionals, but that's just me.  This is more efficient.  The code follows:

if (!dsSpecQuery.Tables[0].Rows[0]["device_type_end"].Equals(System.DBNull.Value)) 
{
    _EndDate = Convert.ToDateTime(dsSpecQuery.Tables[0].Rows[0]["device_type_end"]);
}

Of course, dsSpecQuery is a DataSet, and the field in question is DateTime out of SQLServer (not that it matters for the conditional).

Tuesday, October 09, 2007 9:38:06 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | Programming | SQL
# Thursday, October 04, 2007

Lord Foul's Bane is a fantasy classic that I have read before; twice, I believe. But it was so long ago, that I have been meaning to re-read it for awhile.  The books I have are so old, Amazon doesn't even have the images to link in.  Hopefully Wikipedia doesn't mind.

Lord Foul's Bane is the beginning of the story of Thomas Covenant called Unbeliever.  He is a modern day man afflicted by Leprosy.  He finds himself unwillingly thrust into The Land, a mystical realm that is able to resolve some of his nerve damage and remove his disease.  But he is wary, knowing it must be too good to be true.  He must deliver a message of Doom to the leaders of the Land, and resolve his inner turmoil of even being there.

Covenant is a reluctant hero with fears and flaws that match our own.  Donaldson's treatment of him is very deep and extremely satisfying when looking for a character that is more realistically complex.  He spends much of this book battling the psyche of the main character himself.  There are others, I am certain, that have written this series up far better than I.  For more, find such a review online.  This is the first book of the first trilogy of the Chronicles of the Unbeliever.  The 2 trilogies were so popular that Donaldson has started the 3rd and final a couple years ago.  The Chronicles of Thomas Covenant are, without a doubt, required reading for any fantasy fan.

Thursday, October 04, 2007 1:23:00 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Books
# Friday, September 21, 2007

Sometimes its necessary to script out data manipulation for deployments or automation.  The easiest vehicle in Windows is Windows Script Host (WSH) using VBScript.  Below is a very basic framework for accessing a database (MSSql) and looping a RecordSet.

''===// Retrieve Data from Database //=====
Const DBSERVER = "SQLDEV01"
Const DATABASE = "Cellular"
Const DBUSERID = "app_user"
Const DBPASSWD = "app_pass"

'' Construct ConnectionString
szADOConn = "Provider=SQLOLEDB;Network Library=DBMSSOCN;Persist Security Info=True;" &_ 
            "Data Source=" & DBSERVER & ";" &_
            "DATABASE=" & DATABASE & ";" &_
            "User ID=" & DBUSERID & ";Password=" & DBPASSWD & ";" 

Set DBConn = CreateObject("ADODB.Connection")
    DBConn.open szADOConn        
    szSqlQuery = "SELECT PhoneID, Field2, etc  FROM Import_Name WHERE PhoneID <= 200"
Set cmd = CreateObject("ADOdb.Command")
    cmd.CommandType = &H0001  ''adCmdText
    cmd.ActiveConnection = DBConn
    cmd.CommandText = szSqlQuery
Set RecordSet = CreateObject("ADODB.Recordset")
Set RecordSet = cmd.Execute(szSQLlc)

Do While Not RecordSet.EOF
  WScript.Echo RecordSet("PhoneID")  
  RecordSet.movenext
Loop

Set RecordSet = Nothing
Set cmd = Nothing
    DBConn.close
Set DBConn = Nothing

Of Course, it's possible to distill this down further, but I didn't for clarity (Consts) and it's better to not use implicit command objects by opening the database directly with the Recordset object.

Friday, September 21, 2007 10:08:01 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
SQL
# Thursday, August 30, 2007

When I am Emperor, I will have a quiet policy to fire any IT worker who starts an office lottery pool.  Not only are they wasting the time of people that are trying to get good work done, but they obviously do not have the mathematical and statistical skills to properly perform a programming or development task correctly.

What they do on their own time is, of course, their own business.  I love those who contribute to Ignorance Taxes.

Thursday, August 30, 2007 10:01:10 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
Rant
# Monday, August 20, 2007

Last week, I posted an entry about a simple call to an MS-SQL database with a warning that it should only ever be used in a quick and dirty scenario.  By that I mean when it doesn't make sense to integrate or create a Data Access Layer or class to do the heavy lifting for you.

The advantages of creating classes to do the data calls behind the scenes are many, not the least of which is easier development in the long run.  Take a look at the following code:

    Query qEmplQuery = new Query(); 
    qEmplQuery.ConnectionSettings = ConfigurationManager.ConnectionStrings["EmployeeDB"]; 
    qEmplQuery.StoredProcedure = "DW.PKG_HRPORTAL.PRC_EmployeeInfo"; 
    qEmplQuery.AddParameter("P_EmployeeNumber", szEmplNum); 
    qEmplQuery.MinutesCached = 12 * 60; 
    DataSet dsEmplQuery = qEmplQuery.RetrieveDataSet("P_EmployeeInfo");

Much easier than even the "simple" call I posted earlier, isn't it.  The beauty of this is that it is also an Oracle call (database agnostic:  the same call for Oracle or MS-SQL makes for easier and standardized development) and is cached for 12 hours.  We also have a coding standard that only parameterized Stored Procedures are used for any kind of data access. 

But the most important advantage is that the Query class contains all of the complex coding needed to make this as efficient and "correct" as you know how and never have to think about it again.  This is basic abstraction and Object Oriented Programming fundamentals.  I have used Enterprise Library factories for my calls in Query because of the desire for its good caching and efficient data and network layer calls, but you can use whatever you want. 

In my next series of posts, I will present details of the Query class in order to help build your own.

Monday, August 20, 2007 11:08:46 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] -
.NET | DataBase | Programming
<%--
--%>
Statistics
Total Posts: 189
This Year: 2
This Month: 0
This Week: 0
Comments: 74
Locations of visitors to this page
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Frank W Hagen
Sign In
All Content © 2012, Frank W Hagen
Custom DasBlog theme based on 'Business' by Christoph De Baene