Latest Entries »

Locking Resources at Dinner

One of my students, Jenny :) , showed me a story the used a dinner illustration to deal with locking.  Not only was it funny but it was right on and helped to explain in a different way what resource locking is.  This repost is from Mike Taylor’s blog called the Reinvigorated Programmer located at http://reprog.wordpress.com.  View full article »

Using Connection Strings From the web.config File

Storing your connection strings in the web.config file has several benefits over hardcoding it into your application.  First of all the web.config file (or just the connectionStrings section) can be encrypted to help keep your database connections secure.  Also if the connection string would ever change you can update your connection string in the web.config file without having to recompile your application.  However, using the web.config file tends to be a mystical thing for most beginning .NET programmers so we are going to try to demystify this powerful tool. View full article »

Delegates and Events

Delegates and events can be confusing.  This project was created with numerous comments to help you navigate your way through the application and track what is being called from where.  Essentially this is an example of the publisher/subscriber model.  The event in the BankAccount object fires an event which a method has subscribed to from the Form object.  When that event is fired a delegate is used to pass the arguments to the subscribing method causing it to run and thus yielding the result.  View full article »

Polymorphism

Many people are confused by the concept of polymorphism.  Many other people try to explain to them the concept of polymorphism using examples of animals or other objects.  As I was teaching I found myself showing an example of polymorphism by describing an application so I decided to quickly create the application I was describing so that students could see both the code and the functionality using concepts that they were familiar with (Bank Accounts: Saving and Checking Accounts).  Below you will find my code, explanations and the Visual Studio 2005 project that you can download. View full article »

Dropping All Tables in a SQL Server Database

I ran into a situation using an auto install application that creates a large number of database tables for me the errored.  I wanted to run the installer again but it was taking forever to delete the large number of tables that were created in the database since I did not have SQL Management Studio access and was doing it via a web based interface.  I searched and found a simple way to delete all tables from a SQL Server database.  View full article »

Dropping Constraints on All Tables in a MS SQL Database

I have run into times that I want to delete all the tables out of a database without dropping the database and recreating it.  One example is in working with a prebuilt system such as DotNetNuke or Mango Blog in which the web application has an installer wizard built in that runs and creates all the tables needed for that application.  If something goes wrong during the initial run (not that anything in technology ever goes wrong) I may need to re-run the wizard but will run into problems if the tables that were created during the first try are still present.  In this case I want to delete all the tables that were created and start from scratch.  The problem comes in if there are constraints on those tables that won’t allow you to delete all the tables (this is the situation I ran into with a DotNetNuke install).  So then what do you do?

View full article »

There are a number of free open source web applications that you can use.  A couple of these are BlogEngine.net which is a .NET blog just like it sounds.  Another is Dot Net Nuke which is the most popular open source content managemet system for .NET.  These applications have very easy install and set up but getting them to play well together can be a different story (unless you know how to make them get along!) View full article »

Static Classes and Members in C#

Classes are blue prints for objects.  We create classes and then instanciate those classes to create instance objects which can each contain different data and interact independently of each other.  So what are static classes and why would you use them?  View full article »

Generating Random Numbers in C#

One very common question I get from students is how to generate a random number using C#.  This is very easily done using the Random class.  View full article »

Creating and Using a C# Class Library

A class library is a set of classes, interfaces, and value types that are included in a seperate project from your main forms application.  This library provides access to specific functionality that can be used and updated independantly from the main application.  The class library is compiled as a seperate .dll that is referenced from your application.  Lets take a look at creating and using a class library.  View full article »