跳到主要內容

[ASP.NET] 攔劫SQL EXEC. TIMEOUT

今天系統突然遇到SQL執行TIMEOUT的問題,
程式如何CATCH這個問題,很簡單,運用"SQLException"就可以了,語法如下
            try
            {
                command.Connection.Open();
                command.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                for (int i = 0; i < ex.Errors.Count; i++)
                {
                    errorMessages.Append("Index #" + i + "\n" +
                        "Message: " + ex.Errors[i].Message + "\n" +
                        "Error Number: " + ex.Errors[i].Number + "\n" +
                        "LineNumber: " + ex.Errors[i].LineNumber + "\n" +
                        "Source: " + ex.Errors[i].Source + "\n" +
                        "Procedure: " + ex.Errors[i].Procedure + "\n");
                }
                Console.WriteLine(errorMessages.ToString());
            }

switch ( sqlException.Number )
        {
            case -2:   // Client Timeout
            case 701:  // Out of Memory
            case 1204: // Lock Issue 

            case 1205: // >>> Deadlock Victim

            case 1222: // Lock Request Timeout
            case 8645: // Timeout waiting for memory resource 
            case 8651: // Low memory condition 
            ...
        }

  




留言

這個網誌中的熱門文章

台大教授的網站

陳少傑教授 http://soclab.ee.ntu.edu.tw/http2005/ CAD System Lab 軟硬體共同設計 (Hardware-Software Co-Design) Introduction to Electronic Design Automation 計算機結構 (Computer Architecture) 陳耀文教授 Introduction to Digital systems, Spring 1998 Introduction to VLSI Design, Fall 2000 Physical Design for Nanometer ICs, Spring 2007 Algorithms, Fall 2007 NTU SOC VSLI-EDA

[Windows 8 / 8.1 App] Deploying enterprise apps -- Sideload with DISM

DISM的特點:可以針對共同電腦上的所有USER,透過一次部署動作,讓所有USER都能使用APP. [開始部署] 1.從Server複製封裝好的程式(整個Folder:AppPackages)到本機(透過隨身碟或網芳) 2.搜尋“PowerShell”,用滑鼠右鍵選擇搜尋結果,選擇下方APP Bar的“Run as Administrator” 3.輸入指令:「DISM /Online /Add-ProvisionedAppxPackage /PackagePath:C:\appPackage\App1_1.0.0.0_AnyCPU_Test\App1_1.0.0.0_AnyCPU.appx /SkipLicense」,輸入完畢後按下“Enter” 4.安裝時間會比另一種方式還久一點...安裝完畢畫面。 5.本機的所有user都能使用此App (ex:Yoko)