Compartilhar via


Why care about opening connections either?

If a business app developer shouldn't care about closing a connection, it should care less about opening it.

This step prior to executing any statement against a database seems natural to most of us today because it's what we've been doing for ages now. However, connecting to a database implies a lot of knowledge and a developer should never care about this.

Also lots of quite deep technical decisions are made at the connection statement. The "connection string" is usually a text blob of all sorts of potentially dangerous knobs and levers: resource restrictions (pool management params), timeouts, security configurations, etc.

How many apps fail to work when moved from dev to test and then to production because the connection string is "hardcoded" or is buried somewhere in an obscure .ini (or .config) and assumptions on one environment are simply wrong in another?

Again, connection to a db is a serious business. The underlying architecture in which a program or component runs should take care of that for all of us simple mortals writing "business logic". Database connectivity, location, security considerations are all a different "concern" and its better to keep it separated from the business code.

Comments

  • Anonymous
    January 21, 2005
    Willing to know who is guilty ? ;-)
    Microsoft !!

    You waited too long to make it easy to call "Connection Settings" dialog like one from IDBPromptInitialize::PromptDataSource from managed enviroment ( at http://msdn.microsoft.com/library/en-us/oledb/htm/idbpromptinitializepromptdatasource.asp )

    I've suggested this 1 year and 21 days ago as 110191227 at betaplace.
    I've got an answer from Microsoft product groups that it was fixed. But answer were dated 2 April 2004 (too close to April Fools day ;-)

  • Anonymous
    January 21, 2005
    This has nothing to do with databases. It has a lot to do with good programming practices instead. You're not supposed to hardcode constants in code (if you remember you programming 101 course), you're supposed to group them somewhere and then decide whether they're truly constant, or whether they are environment dependant but can be obtained automatically (like the Windows folder, for instance) or environment dependant and must be configured by an administrator (like the connection string).

    The SqlConnection is not the problem. Developers' knowledge (or lack of it, thereof) is the main culprit.

  • Anonymous
    January 22, 2005
    The comment has been removed

  • Anonymous
    June 01, 2009
    PingBack from http://uniformstores.info/story.php?id=723

  • Anonymous
    June 01, 2009
    PingBack from http://uniformstores.info/story.php?id=14712

  • Anonymous
    June 17, 2009
    PingBack from http://pooltoysite.info/story.php?id=5840