Generic SQL creator

Filed under: General — russell @ 2:42 pm

I have a project where I need to create a generic SQL writer in .Net. Thanks to Microsoft I can just copy code (at least for the SQL oledb).


.Net 2.0 seems to do a better job of this... expanding the capabilities to other datasources besides OLEdb such as ODBC

Smart People and Dumb Ideas

Filed under: General — russell @ 1:47 pm

Read a really good essay on smart people who defend really dumb ideas. It is a really good piece. [edit] How many times can I say really?[/edit] Here is just one quote:

Put simply, the fact that you’re not dead yet doesn’t mean that the things you’ve done up until now shouldn’t have, by all that is fair in the universe, already killed you. You might just need a few more data points for the law of averages to catch up, and put a permanent end to your short term thinking.

You can read it yourself here:

[edit]Scott writes other very good essays... I went back and read several. He has an interesting perspective on work, creativity, management, and personal interaction.[/edit]



Filed under: General — russell @ 2:54 pm

Datatype mis-matches being caught at compile time versus runtime (Oh what I wouldnt give). With the amount of data work that I code, it is always an issue to deal with data that does not match its storage format. For example I have a structure that expects an integer and the user (or database) gives it a string. Either you code to protect it (can you say validate validate validate), or your code blows up at runtime. Enter "generics."

Using Generics, you do not need to fix the data type of the items used by your objects/code. Instead, you use the new keyword: "Of" which identifies the data type parameter on a class, structure, interface, delegate, or procedure. For example:

Public Class MyStack(Of itemType)
Dim stackA As New MyStack(Of Integer)

This is taken from a recent Oreilly article which can be found here: CLICK



Personal knowledge management — interesting? Or repackaging?

Filed under: General — russell @ 5:52 pm

Read an interesting article on conceptual personal knowledge management software. The approach is interesting but I think it represents too huge of a paradigm shift for most people. My experience is these things have to aclimate gradually to the masses. Either way, Dave Pollard's (the author) view is an interesting one and worthy of additional research. Heres the link for further reading:


also a good reference for other generalized "knowledge work:"


More on threading in VB

Filed under: General — russell @ 6:05 pm

Found another article on passing parameters to threads in VB.Net. Unbelievable. This may make VB.Net extremely powerful.



People actually reading my blog

Filed under: General — russell @ 10:34 am

It always suprises me when I get e-mail regarding my blog. My first mail/comment was from JK @ JKontherun. This was over a year ago, and my blog stuff was so screwed that I could not even reply. (BTW JK if you see this, glad to see things seem to be getting better for yah -- I still follow your writing -- on my rss dose now).

JK's blog/site/podcast is a great resource for mobile/tablet/gadgets info. BTW I am yearning for that Fujitsu T4010. Screeeming for the high resolution tablet (1024x768) just aint enough...

Anyway got an email from someone who read an obscure post I wrote on cygwin and php (actually over more than a year ago -- I upgraded my blog software after not being able to reply to JK; hence the october date).

Ok I am rambling again... suppose thats the point tho... I am always suprised people actually read this stuff.


SQL hack for multiple parameters

Filed under: General — russell @ 11:34 am

Ever have to write sql where you optionally have criteria... like a multivariable search form? You know like looking up a person by first name, last name, address etc where you may have one or more of those options filled in by the user.

I found an interesting blog that talks about using COALESCE. Instead of building the where criteria iteratively (i.e. strWhere = strWhere + "lastname = ? " ... strWhere = strWhere + firstname = ?") you can use COALESCE. It is an interesting read. Basically COALESCE returns the first non null value passed in.

I summarize here (you can get the details by following the link). The magic is that the code basically makes fieldname = fieldname when there is no parameter given for the search. It has one problem: using the code below as an example... what happens if both lastname and @lastname are null. This resolves to '' = NULL which is false, breaking the query. I stand corrected (by Scott Elkin): If both lastname and @lastname are null the third argument to COALESCE is returned.

SELECT * FROM Customers
  ISNULL(firstname,'') = COALESCE(@firstname,firstname, '')
  AND isnull(lastname,'') = COALESCE(@lastname,lastname, '')
  AND isnull(phone,'') = COALESCE(@phone,phone, '')
  AND isnull(email,'') like COALESCE(@email,email, '')
  AND isnull(address,'') like COALESCE(@address,address, '')