Wednesday, September 20, 2006

I love .NET, I hate .NET

Recently I developed an ASP.NET application that required access to a database. So far no problem. I have done that several times before and was confident to bring the project to an early end.

During the coding phase I had to make a decision on how to access the database. Usually I would write seperated insert, update and delete procedures in code behind pages. In this particular case it seemed to be appropriate to use an Object DataSource and a GridView control.

So I dropped a GridView into the page and made an new DataSource, choosing the Object DataSource from the wizard. Then I created a class file in the Apps folder to isolate data access there.

I got the records to show in no time and I love .NET for its ease of use.

Next I tried to update records using the Edit functionality of the GridView. This was not a trivial task. First the call to the update member function would throw exceptions at me right, left and center. It turned out (undocumented) that the parameters for the function calls need to have the exact names as the fields in the database table to be altered.

Changing the fields in the GridView works fine, the changed value is forwarded to the update function. However, changing the value in the Row of the Dataset seems to be impossible. Calling the code from a C# program works fine, doing the same out of a ASP.NET class does not work.

I confess, I resorted to the oldfashioned way of updating the database directly to keep the schedule.

I hate .NET for it's non-consistent working and its lack of dokumentation.