While try to connect to SQL server, I keep getting this error.
Solution is simple but wired, details please refer to William Vaughn’s blog
There are two solutions, I took the simplest one – when exception thrown, try to open connection again.
using (conn = CreateConnection()) {
try {
conn.Open();
}
catch {
/* http://betav.com/blog/billva/2008/11/solution-forcibly-closed-sql-s.html#more */
conn.Dispose();
conn = CreateConnection();
conn.Open();
}
//...
}
沒有留言:
張貼留言