David Yardy PE, MCSD.NET

just give me the source...

August 2008 Entries

String.Trim method - Removes all occurrences of white space characters from the beginning and end of this instance.

Trim(var) method - returns a string with no leading or trailing spaces

Yes, there is a difference between these.  The String.Trim will remove any non-visible characters such as line feeds and carriage returns.

How I came across this was as a result of an odd exception I am getting from an application.  Randomly the NameValueCollection after a postback will have an appended or prepended line feed.

i.e.
hidCustomerID: -1
hidCustomerNo: 0
hidCurrent: True

hidOrderID: -1

When the codebehind tries to ctype(hidCurrent, Boolean) it recieves True or False with additional hidden line feeds.  This is within an ASP.NET 2.x web application.  I have yet to find the source of this problem but I am hoping the String.Trim() will help me out here.  If you have any ideas please let me know what may be going on here.

The following is a SQL Script that can be run in a database to return all tables and columns where a particular value is present.  This can be used for strings or values with a small modification.

This type of thing is great when moving applications/products between servers.  This is certainly a good script to include in your master table to be used over and over.

DECLARE @value VARCHAR(64)
DECLARE @sql VARCHAR(1024)
DECLARE @table VARCHAR(64)
DECLARE @column VARCHAR(64)

SET @value = 'valuehere'

CREATE TABLE #t (
    tablename VARCHAR(64),
    columnname VARCHAR(64)
)

DECLARE TABLES CURSOR
FOR

    SELECT o.name, c.name
    FROM syscolumns c
    INNER JOIN sysobjects o ON c.id = o.id
    WHERE o.type = 'U' AND c.xtype IN (167, 175, 231, 239)
    ORDER BY o.name, c.name

OPEN TABLES

FETCH NEXT FROM TABLES
INTO @table, @column

WHILE @@FETCH_STATUS = 0
BEGIN
    SET @sql = 'IF EXISTS(SELECT NULL FROM [' + @table + '] '
    --SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) = ''' + @value + ''') '
    SET @sql = @sql + 'WHERE RTRIM(LTRIM([' + @column + '])) LIKE ''%' + @value + '%'') '
    SET @sql = @sql + 'INSERT INTO #t VALUES (''' + @table + ''', '''
    SET @sql = @sql + @column + ''')'

    EXEC(@sql)

    FETCH NEXT FROM TABLES
    INTO @table, @column
END

CLOSE TABLES
DEALLOCATE TABLES

SELECT *
FROM #t

DROP TABLE #t

Back from vacation and back into the routine of work and I am ready to get in shape.  City living and a ‘developers’ lifestyle has left my body in rough shape.

My wife and I recently invested in some home exercise equipment and I assembled it today.  I was scanning some blogs this evening and came across a couple of other individuals in similar modes.  Rob Conery posted about the onehundredpushups ‘program’ and thought this is good timing.

So my goal is to do my time (2 – 30 minute sessions) on our home equipment daily as well as the 100 pushup plan.  I did the initial test and with sore arms I completing this post.

For my friends out there, if you also get involved and do the program with me (and complete it) I will buy and have delivered your choice of merchandise from their site.  Let me know if this sounds too good. I am serious.

I start day 1 tomorrow.  Let me know if you like my offer.

As you are listening to these realize that it is impossible not to think of someone you know.  That is just funny.

It Works on My Computer Guy - “dozens of dependencies”, “replace the production server with your development pc” - “all in a days work”

Overly Complicated App Guy – “18 abstraction layers”, “what the hell were you thinking”

Mr “I can build your own version of asp.net better than Microsoft” Guy – very very funny!!

Before you rush to download SQL 2008 you may want to read the following KB article which warns that Visual Studio 2008 SP1 ‘may be required’ for SQL Server 2008 installations KB956139 (found here)

”Because certain SQL Server 2008 features install components that are also part of the release version of Visual Studio 2008 SP1, SQL Server 2008 requires Visual Studio 2008 with SP1. If Visual Studio 2008 without a service pack is installed instead, it may not work correctly after you install SQL Server 2008.“

Currently Visual Studio 2008 Service Pack 1 (SP1) is in beta at the current time.  I do not know the expected delivery of SP1 but should be soon (hang tight).

category: SQL Server

With a new laptop there have been quite a few things I have had to configure again.  One of those is the default source view application related to Internet Explorer.  The following instructions apply to Windows XP (not sure yet on Vista).

I thought by changing the HTML Editor within IE (Tools - Internet Options - Programs) would have fixed the problem.  Nope, that did not work.  The following however does work nicely.

Run Regedit

HKEY_LOCAL_MACHINE
|- Software
|-- Microsoft
|--- Internet Explorer
|---- View Source Editor
|----- Editor Name (Default) = "C:\Program Files\TextPad 4\TextPad.exe"

If 'View Source Editor' doesn't exist you will need to create then create the key 'Editor Name' and set the value to the path to the editor that you are going to use.

I know other individuals like Notepad2 or SlickEdit

What editor's do you use?

category: Tools