Generally speaking one connection is always does better performance than opening new ones. However, if several clients are constantly opening new connections and never closing them, then you are exhausting the resources (you can set the max number of connections an SQL server can take). So then it is advised to close connections and reopen them when needed. However, in modern SQL servers and clients you have a so called connection pool, which takes care of keeping connections open as long as they can be, and give these opened connections to the clients when they need them. That gives you an optimum performance with better resource handling, so yes, opening and closing is a good idea. Tamas On Wed, Jun 29, 2011 at 10:48 PM, V G wrote: > Hi all, > > 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 th= at > will present various import/export functions, search parameters, etc. > > 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 an= d > execute multiple queries (in sequence) from that single connection? > > I know it doesn't *really* matter, but, you know, principles... > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > --=20 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .