Here are some samples for using NetTiers 2 CTP with DataGridView controls. These
were developed on Net Tiers 2 CTP nightly build 2006-02-18, CodeSmith 3.2, VS 2005,
SQLServer 2005, .Net 2.0 and Windows XP Pro. The examples are in C#. The Microsoft
Enterprise Library was not used, as NetTiers2 CTP configuration currently does not use
it.
I’ve included some VS2005 notes and tricks, as I keep finding out it’s quirks for building
data-bound controls.
Setting Up
Setting up the DB
Instead of using the Northwinds DB, I’m using a DB created for these examples, called
testdb. The attached zip has scripts for creating it, populating it, and creating the user-
defined functions and stored procedures. Later examples make use of custom procedures,
and explores how NetTiers2 handles them. Extract the zip to a dir. The examples will
show it in C: emp estdb.
Setting up the Testdb database:
Using SQL Management studio, run the included create_testdb.sql to create the Database
itself. Run the included create_testdb_schema.sql to create the tables. Run the included
populate_testdb.sql to populate the tables with data.
Setting up VS2005
Create a new blank VS2005 Solution, in the C: emp estdb directory, name it whatever
you want (in the examples, it is TL.Test). Add a new Solution Folder to the blank
solution, called NetTiers.
Setting up NetTiers 2 CTP
Copy the CTP nightly build to a directory of your choice. Right-click the NetTiers.cst file
and “Execute” the nettiers.cst template. The .zip includes a nettiers_testdb.xml file that
will generate the NetTiers code for these examples. Load the nettiers_testdb.xml. The
.xml file in the example specifies OutputDir as C: emp estdb; Don’t turn off execute
SQL. Execute the template. It will create new subdirectories in the C: emp estdb
directory, named TL.Test.BLL, TL.Test.DAL, TL.Test.DAL.SqlClient, TL.Test.UnitTests.
It also creates SQL and References subdirs,
Adding the NetTiers code to the VS 2005 Solution
Under the NetTiers solution folder, “add existing project” three times, each time
specifying one of the three VS 2005 projects created by the NetTiers execution step.
These are the TL.Test.BLL project, the TL.Test.DAL project, and the
TL.Test.DAL.SqlClient project. Each project will be found in the TL.Test.BLL,
TL.Test.DAL, and TL.Test.DAL.SqlClient subdirectories under the C: emp estdb
directory. The SQL and References subdirectories don’t need to be added to the solution..
Build the TL.Test.BLL project (it should build OK at this point). Select the TL.Test.DAL
project , and add a Project reference to TL.Test.BLL.