Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot connect to SQL Server: Failed to retrieve data for this request

I have been writing a program in c# using Visual Studio 2012. This program makes numerous calls to the database, and everything has always worked perfectly; never had to mess with any configurations to get it to run. A few days back, I received a new computer. After setting everything up, I was trying to run my program but it kept failing on the database calls because it was timing out. I deleted the old connection string and tried connecting to our backup database. Using the Server Explorer, I created a new connection; after filling in all the information, I used the Test Connection button and was told the test succeeded. From the server explorer, I then tried opening the Tables folder, but it didn't work. After about 30 seconds, I got the following error: Failed to retrieve data for this request. Lock request time out period exceeded.

I tried refreshing the connection several times, restarting the db, restarting visual studio, even restarted my computer. I tried connecting back to the original db and got the same result, so I'm sure it's computer-specific and not related to the db. I have already verified that the windows account I am logged on as is a sysadmin. We use SQL Server Authentication, and the account Visual Studio is attempting to connect to is also a sysadmin. I have completely disabled my firewalls as well. I have searched high and low on the internet for an answer, but the only cases where I could find error messages similar to mine were very specifically related to ASP. What I don't understand (and what's difficult to search for) is being able to successfully connect to the db, yet unable to retrieve any data. Any help would be greatly appreciated!

Additional Information: I am using LINQ to SQL class in my project. Target framework = 4.5

Update: I marked the answer as Accepted, but I'll elaborate here in case anybody else ever runs into this same problem. There were two open processes, one of which belonged to me, which is what I assume was allowing the Test Connection to work. After killing all open processes, I wasn't able to connect back to the DB at all. I then restarted the DB service (which is on our LAN, not local) and that worked. I no longer think it had anything to do with the new computer; it just happened simultaneously to whatever caused the issue and caused me to go down the rabbit hole.

like image 319
Darian Everett Avatar asked May 28 '26 16:05

Darian Everett


1 Answers

A very fine answer by a gentleman here Its a copy paste so to clear air i just wanted to help our friend .Original post can be found at the link above.

  1. connect to the MASTER database of the server with the offending database
  2. run the query below to find what transactions are open
  3. kill any transaction that is blocking the SYSTEM SPIDS (1 to 50)

select * from master..sysprocesses where blocked <> 0

go sp_who2 go

-- find the blocked SPIDS, then check for open trans below, any value other than 0 means an open tran

SELECT distinct(open_tran) FROM master..SYSPROCESSES WHERE SPID=<suspect SPID>

-- now kill it! kill

The database will go back to normal as soon as the kill ends. No service to restart, no boot required.

By -MauricioRPP

like image 123
Suraj Singh Avatar answered May 31 '26 04:05

Suraj Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!