tags:

views:

198

answers:

3

I've been doing a little work with SQL Server and C# and every time I run the darn thing the connection times out unless I start services.msc and manually restart the service (SQL Browser Service). It's already set to automatic, does anyone know why it would do this? I'm not an advanced programmer, more of an intermediate one. Once I do restart this service it works fine as long as I keep using it. If I stop using it for more than 30 minutes I have to restart it again.

+1  A: 

Have you checked the SQl Server Log and the windows event log?

Can you supply some more info., such as the C# code you are using to open/close the connection, the connection string etc.

Mitch Wheat
I'm not sure where to find that log!?!
Lucas McCoy
@Tony Romo: you will need the relevant permisions: Open SSMS, goto to the server node and expand it, then expand the Management node -> SQL Server Logs (I don't think you can see it without the right perms). Windows event log can be opened with Event viewer obviously.
Mitch Wheat
What exactly is SSMS, I'm using Visual C# 2005 Professional Edition and SQL Server 2005. When I open up SQL Server 2005 in all programs all I see is a folder that says configuration tools, from there I have to choose on of these 3 options: Config. Manager, Error Reporting, and Surface Area thingy.
Lucas McCoy
SSMS = SQL Server Management Studio
Mitch Wheat
@Tony Romo: if you are not seeing "SQL Server Management Studio" at the smae menu level as the folders you mentioned, I would assume that the SQL Server 2005 client tools has not be installed. Insert the install disk and select clent tools...
Mitch Wheat
@Tony Romo: once you have SSMS, run it, right click on your database, and select properties, then select Options and check that autoclose is set to false (as @gbn suggested).
Mitch Wheat
I don't have that install disk because I got SQL Server from installing VS 2005 Pro Edition.
Lucas McCoy
Mitch Wheat
A: 

Can you connect to the SQL Server by name through SSMS without fiddling with the Browser service (I'm not even sure this really requires the Browser service depending on how you connect)? i.e. does it appear to be running fine except when your program causes it to crash? And once you've restarted it does it work fine repeatedly or do you have to keep restarting it as you use your program?

What version of SQL Server 2005 (and what service pack level) are you using?

Cade Roux
+1  A: 

Is autoclose kicking in?

Defaults to ON for SQL 2005 Express version, but it could have been set for other versions. The database should open automatically though...

Is it a query from the app that times out? Or simply trying to connect to the server to run, say, SELECT @@SERVERNAME?

gbn
@gbn: checking 'autoclose' is a good suggestion...
Mitch Wheat