Chapter 18. Getting and staying connected—or not

 

William Vaughn

It seems that I spend quite a bit of my time answering questions—from family, friends and neighbors—who want to know how to resurrect their computers, or from developers who need to figure out how to get around some seemingly impossibly complex problem. Thankfully, not all of their problems are that complex. I expect that many of you are confronted by many of the same queries from those that look up to you as a technical resource—like the doctor who lives up the street who listens patiently while you describe that pain in your right knee.

A couple of the most common questions I get on the public Network News Transfer Protocol (NNTP) newsgroups (such as Microsoft.public.dotnetframework.adonet and ..sqlserver.connect[1]), are “How do I get connected?” and “Should I stay connected?” This chapter attempts to explain how the SQL Server connection mechanism works and how to create an application that not only can connect to SQL Server in its various manifestations but stays connected when it needs to. I don’t have room here to provide all of the nuances, but I hope I can give you enough information to solve some of the most common connection problems and, more importantly, help you design your applications with best-practice connection management built in.

1 No, I don’t hang out on the MSDN forums—they’re just too slow.

What is SQL Server?

Understanding the SQL Server Browser service

Diagnosing a connectivity problem

What is a connection?

To connect or not to connect...

Connection management

Connection strategies

Establishing a connection

The server key

Trusted or untrusted security?

Accepting user login credentials—or not

Accessing user instances

Connection pooling

Closing the connection

Summary

About the author