Tuesday, May 19, 2009

DataSets and TableAdapters

Before .NET 2005 I accessed data the same way every one had for years, build a connection string to a database, build a command, open the connection, run the command and close the connection. That was the process if you were lucky and didn't have to do inserts or cascading deletes or updates. Some poor folks still do it this way, typically saying crazy things like "it gives me more control over what i'm doing". Complete nonsense. I know this because i've said it myself many times.

What is the solution then? Let .NET handle it the way it handles the building of your buttons, labels and textboxes. For over 2 years I tried to use it and it seemed too complicated, I still cannot point to one site that shows how to do this. Some sites may show how to setup the connection and some basic functionality but that's it, i need more than to just populate a datagrid. I created a project and swore off all handling of the data, I wanted to see if .NET could handle it all. At several points I almost gave in, almost added just a few lines of my own code because I couldn't find a suitable solution anywhere, but I stuck to it and finally got it right. Now that I got it and understand it, I will NEVER handle my own connections etc. again.

In the next couple of posts I will document what I have learned.

No comments: