2011年11月22日

[SQL]A connection was successfully established with the server, but then an error occurred during the login process

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();
}
//...
}

沒有留言:

Blog Archive

About Me