Virtual (and Free) Visaul Basic.Net Programmer's Cookbook

This is a very useful reference because of the problem/solution format that it employs to present the Visual Basic.Net language. However, I’m waiting for Microsoft Press to re-publish it for VB.Net 2005 before I buy a copy. Until then, I’ve discovered that you can download the complete source code for all examples in the book from Microsoft Press. After downloading the solutions and source code to your local computer, you can use the online table of contents to find the solutions you are looking for.

Storing Passwords in a Database

We all know that you should take some steps to obsfusicate passwords stored in the database so that they are not exposed to users with read access to the table that they are stored in. This Ask Tom post gives straightforward examples of how to obsfusicate passwords stored in an Oracle database either by encryption or by hashing.

Implementing Dispose()

A best practice when you create a classthat uses unmanaged resources is to implement the Dispose() method of the IDisposable interface. Even if your class is not using unmanaged resources directly but contains members that do (i.e. ADO.Net objects), it’s a good idea to implement Dispose() to call Dispose() on those members.

In order to properly implement Dispose(), you have to follow some rules. You can find an example of how to go about this in this MSDN library article on implementing Dispose() and Finalize().

Trouble Writing to the Event Log from ASP.Net?

This Microsoft KB article offers some work arounds.

You’re not alone. The ASP.Net worker process account doesn’t have permission to create a new event log source. This Microsoft KB article offers some work arounds.

I’ve also had this same problem with Windows Service applications that try to write to the event log, so it would seem that the local service account doesn’t have permission to create an event source either (eventhough writing to the event log is such a common function of Windows Services that it is used as an example in the otherwise helpful tutorial from Microsoft!). Although I came up with another solution at that time (runing the code to write to the log once from a command line project while logged in as a user with the proper permissions), I’m sure the solutions in the above article would work, too.

Google's Starting to Scare Me

OK, Google, I know you’re listening, but I don’t know whether to tell you to keep up the good work, or to stop taking every idea I have and turn it into a built in feature of your site!

OK, Google, I know you’re listening, but I don’t know whether to tell you to keep up the good work, or to stop taking every idea I have and turn it into a built in feature of your site!

Just a few weeks ago I was talking to a friend about how the LA Metro’s transit trip planning site hasn’t worked for months and that I was thinking of trying to pull together a replacement using the Google API. Next thing you know, Google Transit is in beta for Portland and coming to a city near you. This week I was making a mix CD for a few friends, and doing a lot of web research on the bands to include some facts in the liner notes. No sooner did I have the thought, “How come Google hasn’t gotten themselves into the online music scene” when (BAM!) Google started providing album information about popular artists.

I guess the only good idea left is to go work for Google.

.Net Date Format Strings

I keep forgetting these and not being able to find them in the MSDN library without going through pages of locailzation jargon, so I’ve decided to reprint this list that I found on vb-helper.com.

  • d – Short date
  • %d – Day number
  • M?d – Month and day number
  • dd – Day number, two digits
  • ddd – Abbreviated day name
  • dddd – Full day name
  • f – Full (long date, short time)
  • %f – Fractions of second, one digit
  • s^f – Seconds and fractions of second, one digit
  • ff – Fractions of second, two digits
  • fff – Fractions of second, three digits
  • ffff – Fractions of second, four digits
  • fffff – Fractions of second, five digits
  • ffffff – Fractions of second, six digits
  • fffffff – Fractions of second, seven digits
  • g – General
  • %g – Era (eg. A.D.)
  • y-g – Year and era (eg. 5-A.D.)
  • gg – Era (eg. A.D.)
  • h – Hour (1-12) (Doesn’t seem to work)
  • %h – Hour (1-12)
  • h-m – Hour and minute
  • hh – Hour (01-12)
  • H – Hour (0-23) (Doesn’t seem to work)
  • HH – Hour (00-23)
  • m – Month name and date
  • %m – Minute (0-59)
  • hh_m – Hour and minute (0-59)
  • mm – Minute (00-59)
  • M – Month name and date
  • %M – Month number (1-12)
  • M+d – Month number and day number
  • MM – Month number (01-12)
  • MMM – Month abbreviation
  • MMMM – Month name
  • s – Standard sortable date/time
  • %s – Seconds (0-59)
  • s^ff – Seconds (0-59) and fraction of seconds
  • ss – Seconds (00-59)
  • t – Long time
  • %t – First letter of AM/PM designator
  • hh+t – Hour and first letter of AM/PM designator
  • tt – AM/PM designator
  • y – Short date
  • %y – Year (0-99)
  • m-y – Month and year
  • yy – Year (00-99)
  • yyyy – Year (0000-9999)
  • z – Doesn’t work
  • %z – Whole hour time zone (-12 to +13)
  • Zone:z – Zone – and whole hour time zone (-12 to +13)
  • zz – Whole hour time zone (-12 to +13) with two digits
  • zzz – Time zone in hours and minutes})