ASP.Net blows chunks
Really big nasty chunks! I guess I’ve been spoilt by working with rails, and to be fair it’s not really ASP.Net I don’t like, it’s ADO.Net. I mean really, who wants to write 12 lines of code to fill a grid with data from a database!
1. construct a new SqlConnection object
2. construct a new SqlCommand object
3. construct a new SqlParameter object
4. set the parameter name
5. set the parameter value
6. add the parameter to the select command
7. construct a new DataSource object
8. construct a new SqlDataAdapter object
9. fill the DataSource using the SqlDataAdapter
10. connect the DataSource property of the grid to the DataSource object constructed earlier
11. call the DataBind method of the grid to actually load the data
12. close the database connection
I guess it’s all supposed to be used via the GUI editing tools which should build a lot of that stuff for me automatically. I assume the GUI built data binding can handle parameters for the select.
Another feature of Rails that I’m missing in ASP.Net is partials. I’m using master pages to give me some of the things that I would have used a layout for in Rails, but there doesn’t seem to be anything quite like partials in ASP.Net
Fortunately for me it’s a simple application I have to build so there are only a couple of repeated sections of code.
Also, what’s up with not allowing the TextBox control to be bound to a DataSource? I’ve got better things to do with my time than to write a line of code for each TextBox on my form to fill it with data and another to then put that data back into a DataTable so I can have it saved to a database.
A word of advice to all ASP.Net developers who read this, don’t use Ruby on Rails. It will only make you realize how bad you’ve got it
4 Comments so far
Leave a reply
Dreamhost
For asp.net, since the data grids are usually display only, you can skip step 7-9 and assign the reader right to the data source. I agree though, Ruby On Rails makes things so much easier.
What you are comparing is apples to some sour grapes.
Dude, I have never written one piece of code more than once in .NET.
You need to give it as much time as you obviously have given ruby on crack.
But seriously, I can remember looking at ASP.Net when it first came out and thinking, why would anyone write web apps any other way. Then I used it for a while and discovered by
[...] Daniel’s Stuff » Blog Archive » ASP.Net blows chunks [...]