Book I recently read: Accelerated C# 2005 by Trey Nash, Apress

This is a great book if you are already familiar with object oriented languages such as Java or C++.  Unlike some of the other bricks out there on C# this book assumes you know object oriented coding and glosses over some of the basics.  It get’s right to the stuff you need to get up and running with C# quickly.  I also liked the first few chapters that explain the Common Language Runtime (CLR) and the .Net Framework.  These chapters give you the knowledge you need to understand how the system internals work and what the CLR and the .Net Framework take care of for you.  After that, the book mixes some chapters on the basic syntax of C# with some advanced concepts.  The basics include a general C# syntax overview, working with strings, and detailed info on Structs, Classes, Objects and Arrays.  It also includes some more advanced topics such as Threading, Generics, Delegates, Events and Operator Overloading.  Coming from an object oriented background I loved this book.

Posted in | 0 comments

Determining Table Sizes of Your DB in SQL 2005

I currently have a SQL 2005 database that seems larger than it should be.  It’s running about 5 gig, which is not very big, but once you add in all backups and such it is taking up too much space for my Virtual Server.  In SQL 2000 there was a HTML based page you could open to determine the size of you tables in number of rows and in KBs.  This page is nowhere to to be found in SQL 2005.  I did some research and came accross a great article on how to get this information here.  I will also detail how I handled it below:

First I created a table in my DB named TableSizes.  Here is the script for that:

CREATE TABLE [dbo].[TableSizes](

            [tablename] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

            [rows] [int] NULL,

            [reserved] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

            [reserved_int] [int] NULL CONSTRAINT [DF__TableSize__reser__33928E3B]  DEFAULT ((0)),

            [data] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

            [data_int] [int] NULL CONSTRAINT [DF__TableSize__data___3486B274]  DEFAULT ((0)),

            [index_size] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

            [index_size_int] [int] NULL CONSTRAINT [DF__TableSize__index__357AD6AD]  DEFAULT ((0)),

            [unused] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,

            [unused_int] [int] NULL CONSTRAINT [DF__TableSize__unuse__366EFAE6]  DEFAULT ((0))


Next I created a the stored proc similar to the one in the article I mentioned above.  Except instead of using a temp table I’m storing the data in my TableSizes table.  I don’t have anything against temp tables I just like the idea of that data being saved of so I can use it later for reporting and such.  Here is the stored proc:

CREATE PROCEDURE dbo.spPopulateTableSize



truncate table TableSizes


-- Populate the temp table...

EXEC sp_MSforeachtable @command1=

         "INSERT INTO TableSizes


          EXEC sp_spaceused '?'"


-- Strip out the " KB" portion from the fields


   [reserved_int] = CAST(SUBSTRING([reserved], 1,

                             CHARINDEX(' ', [reserved])) AS int),

   [data_int] = CAST(SUBSTRING([data], 1,

                             CHARINDEX(' ', [data])) AS int),

   [index_size_int] = CAST(SUBSTRING([index_size], 1,

                             CHARINDEX(' ', [index_size])) AS int),

   [unused_int] = CAST(SUBSTRING([unused], 1,

                             CHARINDEX(' ', [unused])) AS int)


-- Return the results...

SELECT * FROM TableSizes order by tablename

So now I can call this SP anytime I want and get a great view of the tables, and thier sizes, in my DB.  Hope this helps!

Posted in | 2 comments

Select Method on a DataTable

I thought I would bring this up as an FYI.  This method is very useful for doing in memory searches of your DataTables.  The Select method takes a filter expression as a parameter and returns an array of DataRows that can be looped through.  It’s also a very easy way to determine if certain rows exist in your DataTable.  If you do the select and the length of the array returned is zero, then no rows exist and you can move on.  I’ve used it a few times and thought I’d pass it along.

Posted in | 0 comments

Creational Design Patterns

I completed my presentation on Creational Design Patterns and presented it last Monday.  Sorry for the delay in getting the samples out here!  I took some time off over the Thanksgiving Holiday.  Thanks again to FDC for having me!  If you have any questions or comments about the presentation please feel free to comment on this blog or email me.  Here is the presentation and the demos:

 Creationa Design

Posted in | 0 comments

.Net Framework 3.0 Free E-Learning

Just an FYI there are three free 2 hour courses available from MS E-Learning on .Net Framework 3.0.  There is a class for WPF, Workflow, and WCF.  I think they are just intro classes, but the prerequisites make it sound like they might get into some deep content.  I just signed up so I will keep everyone updated as I go through the classes.  Here is the link if you want to check it out.

Posted in | 0 comments

Behavioral Design Patterns

I completed my presentation on Behavioral Design Patterns and presented it this morning.  Thanks again to FDC for having me!  If you have any questions or comments about the presentation please feel free to comment on this blog or email me.  Here is the presentation and the demos:

Behavioral Design

Posted in | 0 comments

Determining the website that belongs to an IIS process

Today I ran into an issue where there was a w3wp.exe process running on my server that was pegging the CPU.  The only thing I could find about it was that it was running under the user name of NETWORK SERVICE.  I had no idea what site was causing the issue.  I searched online and found this command:


Run this from the command prompt and it will give you the PID to web site mapping.  You might also have to add the PID column to your Windows Task Manager.  Click View.. Select Columns to add this column.

Good Luck…

Posted in | 0 comments

Do you need a car or a USB jump drive?

Posted in | 0 comments

Events and Structural Design Patterns

Thanks FDC for having me for the Events and Structural Design Patterns Talk! I hope you got enough out of it to help you complete your drills or to help you retain some of the concepts from the drills. I would also like to thank those of you who attended this session at the South Colorado Code Camp on Saturday. I hope you got as much out of code camp as I did. I would appreciate any comments on how I can make the talk better. Just email me or insert a comment to this blog post. Here is a link to the zip file with the demos and slides: Events And Structural Design

Posted in | 1 comments

Issue I had while caching a Dataset in ASP.Net

Today I had a bug where pricing on my application was changing every time you clicked the button to search for product.  After running it through the debugger, I discovered that the cached Dataset was retaining the mark ups every time they were applied.  Here is a detail of what was happening:

When the user made a request for product I was going out to get the product based on their user settings (Who the were, what mark up was defined for their company, what market do the do business in, etc.)  These are generic settings that will not change during the session so i was caching this Dataset to alleviate going back to the DB every time.

Next, they would refine there search by the product criteria.  At this point I would get the Dataset out of cache, filter based on the criteria they chose and apply the mark up to the values in the Dataset.

Well, the caching holds a reference to the Dataset so any changes I made to the price in the Dataset was reflected in the cache.  So, if the user performed a search that returned any of those same products, the mark up was applied to the price in the Dataset, which had already been marked up.  So, depending on how many time they searched for the same product, that product got marked up that many times.  Big problem!

To alleviate this I simply copied the Dataset into a new one before I did my mark up.  That way the mark up was never reflected in the cached Dataset.  So the next time that data was received from the cache it still had it’s original price.  Very tricky to spot.  I’m glad it’s over.

Posted in | 0 comments

ASP.Net Web Deployment Projects

I just ran across a great blog entry that explains the Web Deployment Project for ASP.Net.

Scott Guthrie's Web Deployment Blog Entry 

Scott does a great job of detailing how to create these and get them working.  Make sure you read the final portion about creating an MSI based on the output from the Web Deployment Project.  Having an MSI would please most of the system admins out there that are in charge of deployment…

Here is a word document that also does a great job of explaining the Web Deployment Projects

Web Deployment Projects Doc

Posted in | 0 comments

Thanks FDC!

I’d like to say thank you to FDC for having me for the Events and Structural Design Patterns presentation.  Please feel free to email me your questions or comments or just post a comment to this blog entry.  I’d love to here how the drills are going.  I’d also like any feed back you can give on the presentations and how to make them better.

I will also be doing the presentation on Oct. 9th.  The topic will be Behavioral Design Patterns.

Posted in | 0 comments