# Wednesday, October 28, 2009
A simple validation routine to validate a string meets the minimum and maximum length requirements.
Wednesday, October 28, 2009 4:09:54 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, October 14, 2009
WinForm: The base class % could not be loaded.
Wednesday, October 14, 2009 6:27:16 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, October 07, 2009
Interview screening and consulting
Wednesday, October 07, 2009 5:14:00 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 
# Tuesday, September 29, 2009
Using the MasterType directive to programatically access you Master Page.
Tuesday, September 29, 2009 5:34:35 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
Just a general rave about WebSpark, and a rant about PayPal.
Tuesday, September 29, 2009 5:23:27 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, September 25, 2009
Placing page trace information in a file instead of on the page
Friday, September 25, 2009 6:11:05 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, September 23, 2009
Interview question -- the virtual keyword
Wednesday, September 23, 2009 5:45:06 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
Fancy tooltips in WinForms!
Wednesday, September 23, 2009 4:58:23 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, September 22, 2009
Adding a WinForm tooltip without the control..
Tuesday, September 22, 2009 5:38:13 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
Why so few posts recently..
Tuesday, September 22, 2009 5:15:25 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, September 16, 2009
How to enumerate all the shortcut keys in the Visual Studio IDE
Wednesday, September 16, 2009 6:22:12 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 

I am getting settled in my new project, and it only took me a week to get rights to install anything on the laptop! A lot of people would say "Wow, a billable week with no work!" but personally, the days just drag by. I'd much rather be buried in code. I did make some good use of the time though, digging into what documentation I could find and creating a new Functional Specification Document. I did finally get my rights, so tomorrow will be spent installing things and looking into code again.

I did get some reading done though, and I saw that in VS2010 C# will have optional and named parameters. I know the VB crowd (of which I come from) will chuckle a little at that, as that feature has been around forever. Until now, it's required C# developers to overload functions. Nothing Earth-shattering about this feature, other than as part of it, C# will support named parameters and default values as well as part of the implementation (the default values are part of the defiinition of the function).

All Things | C# | CSharp | General | VB.Net
Wednesday, September 16, 2009 5:36:56 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, September 07, 2009
Debugging trick for placing a condition on a breakpoint to assist in speeding up debugging.
Monday, September 07, 2009 11:46:14 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
How to make the Visual Studio debugger break where the error actually occurs.
Monday, September 07, 2009 11:28:20 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Saturday, September 05, 2009

As I was looking through Scott Hanselman's List of Tools for 2009, I saw a reference for Microsoft's Sketchflow (part of Microsoft Expression), which allows you to design (among other things) and work through ideas prior to coding. I am going to check it out this weekend, and maybe some of the alternate tools he recommended for his post.  I might even have to dust off my Table PC, as it seems like a good combination.

Saturday, September 05, 2009 4:55:17 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Friday, September 04, 2009
Tipf of the Day: A brief discussion of the new Extension Methods in .Net 3.5
Friday, September 04, 2009 6:10:29 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Thursday, September 03, 2009
Starting a new project, how to approach it?
Thursday, September 03, 2009 8:41:58 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, September 02, 2009

I can't take credit for this, as I took it from the article How To Get Table Row Counts Quickly And Painlessly on SqlServerCentral.com by Kendal Van Dyke. However, it such a good tip, I had to change it a bit, as I tend to use this a LOT.

First, I made the results a little more "printable" but reducing the table name column. Next, I made it a system proc because when I go onto client sites, I am looking at many databases. I probably don't need to create a procedure for it, but there have been many cases where I trend things, and it would be nice to have this handy. Finally, I added a parameter to allow me to change the sorting. By default, it sorts by table name. I added an optional parameter to allow me to pass in an integer (could have done it a million ways, I know, but I chose to do this solely for my preferences -- feel free to change to yours).

Usagesp_retrieveRowCounts    --- sorts by table name

            sp_retrieveRowCounts 1  ---sorts by row count, then table name

Here's the proc:


USE master
GO

IF (SELECT OBJECT_ID('sp_retrieveRowCounts','P')) IS NOT NULL
BEGIN
    DROP PROC sp_retrieveRowCounts
END
GO


CREATE PROC sp_retrieveRowCounts (@OrderByCount int = null)
AS
BEGIN

    DECLARE @OrderByParm int
    DECLARE @SQLStatement varchar(700)
    DECLARE @OrderByClause varchar(35)
    
    SELECT @OrderByParm = ISNULL(@OrderByCount,0)

    IF (@OrderByParm != 0)
        SELECT @OrderByClause = ' ddps.row_count DESC, o.NAME ASC'
    ELSE
        SELECT @OrderByClause = ' o.NAME ASC'

    SELECT @SQLStatement = 'SELECT TableName = LEFT(o.name,50), TotalRows = ddps.row_count FROM sys.indexes AS i
     INNER JOIN sys.objects AS o ON i.OBJECT_ID = o.OBJECT_ID
     INNER JOIN sys.dm_db_partition_stats AS ddps ON i.OBJECT_ID = ddps.OBJECT_ID
     AND i.index_id = ddps.index_id
    WHERE i.index_id < 2
     AND o.is_ms_shipped = 0
    ORDER BY '
+ @OrderByClause
    
    EXEC(@SQLStatement)

END

--Mark procedure as system object
EXEC sys.sp_MS_marksystemobject sp_retrieveRowCounts
GO


GRANT EXEC ON sp_retrieveRowCounts TO public
GO

 

Wednesday, September 02, 2009 6:34:10 PM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, September 01, 2009

I posted about sp_findsp previously and decided to revisit it. I didn't write it (see previous post for credit/link) but I did add a bit to it. First, I cleaned it up a bit to make it easier to read, and second, I made it so that it is a system proc so I could access it from any db on my server. I may end up doing some cleanup on it's output, but that's all I had time for for now. So here goes, the new version!

USE master
GO

PRINT 'Checking for the existence of this procedure'
IF (SELECT OBJECT_ID('sp_generate_inserts','P')) IS NOT NULL --means, the procedure already exists
BEGIN
PRINT 'Procedure already exists. So, dropping it'
DROP PROC sp_findsp
END
GO


CREATE PROC sp_findsp @s varchar(255)
AS
BEGIN
    DECLARE @msg varchar(255) ,@ul varchar(255)
    SELECT @s='%' + @s + '%'
    
    SELECT 'SP Name'=upper(o.name), Seq=colid ,'SP Line'=substring(text,patindex(@s,text)-5, 30)
    FROM syscomments c , sysobjects o
    WHERE o.id=c.id
    and patindex(@s,text) > 0
    ORDER BY [name]

    SELECT @msg='* Stored procedures containing string "' + @s + '=' + convert(varchar(8),@@rowcount) + ' *'

    SELECT @ul=replicate('*',datalength(@msg))
    PRINT ' '
    PRINT @ul
    PRINT @msg
    PRINT @ul
END
GO

--Mark procedure as system object
EXEC sys.sp_MS_marksystemobject sp_findsp
GO

PRINT 'Granting EXECUTE permission on sp_findsp to all users'
GRANT EXEC ON sp_findsp TO public

GO


All Things | C# | CSharp | General
Tuesday, September 01, 2009 5:20:43 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 

When I go onto a client site, I usually don't have the luxury of designing everything from scratch. There are times (like on my current engagement) if I were given the choice, I'd say scrap it, but usually it doesn't happen that way. It is what it is... been saying that a lot lately!

So one of the tools I find useful is the ability to search for particular field names in the database. This is very similar to sp_findsp I use, which I have posted in the past off the net, but I have modified it so it gets registered as a system procedure.

So here's sp_findfields. It will return a fairly printable representation of the results of all fields which match the passed in string. It's registered as a system procedure in this script, so it is accessible to all databases.

Usage:

sp_findfields '%Contact%'

This will find all fields with the string 'Item' in it. Note you need to provide the wildcard characters.

USE master
GO

IF (SELECT OBJECT_ID('sp_findfields','P')) IS NOT NULL
    BEGIN
        DROP PROCEDURE sp_findfields
    END
GO

CREATE PROCEDURE sp_findfields
(@searchText varchar(50))
AS
BEGIN
    
    SELECT SchemaName = LEFT(TABLE_SCHEMA,10),
        TableName = LEFT(TABLE_NAME, 35),
        FieldName = LEFT(COLUMN_NAME, 40),
        DataType = LEFT(DATA_TYPE, 13),
        DataSize = CHARACTER_MAXIMUM_LENGTH,
        AlloysNulls = IS_NULLABLE
    FROM INFORMATION_SCHEMA.columns
    WHERE column_name like @searchText
    ORDER BY TableName, FieldName
END
GO

--Mark procedure as system object
EXEC sys.sp_MS_marksystemobject sp_findfields
GO


GRANT EXEC ON sp_findfields TO public
GO

Tuesday, September 01, 2009 5:10:15 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, August 31, 2009

Since I am going back into full time consulting, I decided lugging around twenty 800 page books is a bad idea. Tonight, I pulled the trigger in a Kindle DX. A bit pricy, but the fact I can annotate my books (and export the annotations) and read native PDFs, I can see the value in the price. I only wish it allowed you to annotate PDFs, as I know I can put a LOT of things in PDF form and place on there.

So I was noticing Amazon charges for placing RSS feeds on the Kindle, and I decided to either find a service which converts RSS feeds to PDF format, or write one myself. Fortunately, I found Tabbloid, which mails your RSS feeds in PDF format at an interval you specify. Even better, it looks free. I may still write one and put some filtering capability in it, but this is a win for now.

The other gadget I have and just enjoy is my Pioneer XMp3 player. It allows me to record XM content, and place all kinds of music on the Micro SD card. It's still kind of buggy, and with the XM-Sirius merger, I don't imagine that will change, but I still enjoy it immensely.

Monday, August 31, 2009 5:26:21 AM (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |