V G wrote: > Totally off topic, but I'm writing a desktop program (in Visual C# for > MS SQL Server 2005, of all things), for a client who needs to search > his already existing database. Basically a search program for his > database that will present various import/export functions, search > parameters, etc.=20 >=20 > Very simple question: Every time my "Search" button is pressed in the > program, should I create (and close at the end) a new database > connection? Is this good programming practice? Or should I have one > open database connection for the lifetime (while the program is open) > of the program and execute multiple queries (in sequence) from that > single connection?=20 >=20 > I know it doesn't *really* matter, but, you know, principles... In many applications it doesn't really matter, and yours may be one of those. In some it does... for example, when you're doing a lot of queries and the time opening a connection is prohibitive (use and re-use one connection), or when you may have many client apps open that don't use the database a lot (open and close). There isn't really a single "best practice" way to do it; it depends on the application requirements. In any case, make sure you close the connection not only in the course of normal processing, but also when exception occur that throw you out of the normal code path. Typically you'd wrap a database connection in an object that closes the connection when it is destroyed. Gerhard --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .