in

Blog By Bob

Blog by Bob

ADO.NET Silliness

I look at alot of the constructors for ADO.NET and I just have to ask, why? oh God why?

Take, for instance, the relationship between a SqlConnection object and a SqlCommand object.

To me, the clearest and still quickest way to instantiate both would be:

SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServer"].ConnectionString);

SqlCommand command = connection.CreateCommand("select * from blah");

Or so you would think, but even though there is an override for SqlCommand for a command text so you can say:

SqlCommand command = new SqlCommand("select * from blah", connection);

There isn't an override in CreateCommand to slap that query text in there, but at the same time I really don't like having to pass the connection object to the command guy to get them linked, when SqlConnection's CreateCommand factory makes it so clear how things hook together. Sigh, I guess I just need to override it and use my own shiznit.

Published Mar 29 2007, 02:13 PM by Bob

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add
Copyright © :: BlogByBob.com
Powered by Community Server (Non-Commercial Edition), by Telligent Systems