Saturday, March 12, 2005

The Datamodule and .NET Framework

In Delphi we are used to place our dataset controls on a datamodule. This offered natural seperation between the GUI (the form) and the business logic. In .NET however there is no such thing as a datamodule. If you want to use the data components you must place them on your form.
Well that is now the one place where you don't want them to be!

Off course you could make your own class and code your way out, but I find it very usefull if you can visually design your data layer. On the other hand you could use VCL.NET and have full profit of the datamodule again. :-)

In Winforms however there is a very easy way to simulate the Delphi datamodule. It takes just two steps to get one:
(Open a new winform application)
The steps are for Delphi 8 and might be a bit different for Delphi 2005.

1. Choose File - New - Other, choose folder Delphi for .Net projects - New Files.
Choose: Component for Windowsforms
You will now have a component in your project which is a non visual container where you can place non visual components.
2. Drop BdpConnections and adatapters on the component and add the component to the uses of the form.

Off course this works also in Visual Studio 2003.

Well it maybe not the most elegant solution, but it works fine and gives you more control in seperation your GUI and data layer.

No comments:

Use an image as your UIBarButtonItem

Using an image as your UIBarButtonItem in your navigationcontroller bar can only be achieved by using a common UIButton as the BarButtonItem...