Using Codesmith and .netTiers

I recently came across Codesmith and .netTiers. It’s one of the best things to happen to me since i started working in VB.NET. You can view the details of what these two are in their sites. Here’s the gist:

Codesmith is an engine for creating code dynamically based on templates. It saves time. .netTiers is a template for Codesmith which creates code for handling SQL Server databases. It creates classes for performing DML (and other operations) on all database tables. This is done by creating collections. You can use it as simply as a collection!

Now, the tutorial I tried to learn from - their official one - is incomplete! Put simply, it doesn’t work. So, I decided to write my own.

Tutorial

Here’s a project I created while learning to put this netTiers to use. It’s pretty basic but does all three DML operations. To run it, you need to have SQL server running on (local) with the default Northwind database using Integrated Security for login. To change these settings, see the last section of this tutorial.

Download Project.

Run this project and try these tasks:

View the list of Employees. Try typing a name in the text box to see dynamic searching in action. You can also use up, down, page-up and page-down keys in the textbox for navigation.

Enter new employees. (Just enter the values and click on Add.)

Modify past records. This is the most functional part. You can enter an ID in the ID field and hit enter to load that record in the boxes below. If that ID doesn’t exist, you’re shown the view box in which you can select an employee and hit enter to load that.
Changing SQL server database and server

If you want to change these settings, open up the DataConfiguration.conf file from your bin folder and edit the settings. (See screenshot.)

If you download the project and try running it, you’ll notice that it doesn’t work! This is because of the way references are created by netTiers. Here’s what you need to do to fix it. I know this isn’t the right solution. I’m trying to get to do this properly. If you find something, do leave me a note.

If you find something wrong and/or missing in this tutorial, please let me know.