Introduction

No0.1111. C# how to determine the Server2008 Sql can be a common link? Introduction: my program is the need to link Sql… C#.NET how can it… More than 5 times on the wrong start failure? … my fa (Law) Du (degrees) GUI Biao (table) standard is demand link SQL Server2008 and no "Ren" (how ability C#.NET) duty of the do launch detection is not Shi (is) to Pu (PU (PU) through chain Jie (Jie (then) SQL Server2008 specified database if adjacent to defeat is a second and even exceed 5 times wrong on the newspaper launched defeat? Or do not report to launch a defeat indirectly limited company. Start the system to establish a connection to detect is not through the myconn SqlConnection = SqlConnection new (=…… Myconn.Open (); I=0 int; while (I++< & =5; myconn.State;; =ConnectionState.Open) {System.Threading.Thread.Sleep (1000); myconn = SqlConnection (= new); = (&)…… }…… In fact, there are several ConnectionState enumeration value can accurately determine the current connection in what can be connected after the operation began but what is not clear according to your business needs can make this judgment in your own database operations (connection and update) class can achieve the purpose of judgment before each use did not seem too. A direct approach is try catch. I mean the judgment in each database connection place and not just the system starts when you do not know what is the business is generally not so strict by try catch this postprocessing way is enough. Set Timeout in the connection string inside (this is very important otherwise, the default is 30 seconds before the return link cannot connect) and then you get the local connection string package can How many times you write your own code can also use the Microsoft Enterprise Library TransientFaultHandling (this is how many times the number of cycles) of all other actual use of the link string from this place to get