2024年8月26日 星期一

無法使用Database Mail

設定Database Mail時,顯示

Database Mail depends on Service Broker. Service Broker is not active in msdb. Do you want to activate Service Broker in msdb? If you do not activate Service Broker, Database Mail will queue e-mail messages, but will not be able to deliver the messages.

select is_broker_enabled from sys.databases where name = 'msdb';
回傳0,確實沒啟動。

ALTER DATABASE msdb SET ENABLE_BROKER ;

等了好久沒反應。

參考以下重建

https://learn.microsoft.com/zh-tw/troubleshoot/system-center/scom/troubleshoot-sql-server-service-broker-issues

use master
go

ALTER DATABASE msdb SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE msdb SET NEW_BROKER WITH ROLLBACK IMMEDIATE ALTER DATABASE msdb SET MULTI_USER go ALTER DATABASE msdb SET SINGLE_USER WITH ROLLBACK IMMEDIATE ALTER DATABASE msdb SET ENABLE_BROKER ALTER DATABASE msdb SET MULTI_USER go

2024年8月16日 星期五

ReportViewer 工具列顯示中文

VS專案中要升級舊版的report viewer,已經不用再去安裝runtime,直接以NuGet方式安裝Microsoft.ReportingServices.ReportViewerControl.WebForms  150.1652.0 ,但部署後,工具列都是英文沒有中文。

但在bin下其實有本地化的目錄zh-CHT 所以應該有支援多語系,在bing和google了半天都找不到想要的,覺得這二個搜尋引擎好像愈來愈難找到想要的資訊,是我的錯覺嗎???

後來想到用保哥很推薦的felo search(https://felo.ai/),還真的沒讓我失望耶。

輸入了 Microsoft.ReportingServices.ReportViewerControl.WebForms zh-CHT  詳列了做法。主要是在web.config加入以下設定。

<configuration>

  <system.web>

    <globalization culture="zh-CHT" uiCulture="zh-CHT" />

  </system.web>

</configuration>

將zh-CHT 目錄下的dll加入專案參考後,重新部署,工具列就出現中文了。


2024年8月5日 星期一

SQL AGENT無法啟動 無效的物件名稱 'syssubsystems'

有一天一台SQL 2019 主機安裝CU27後,SQL AGENT無法啟動,查看SQLAGENT.OUT記錄檔錯誤如下

2024-08-06 12:00:08 - ! [298] SQLServer 錯誤: 208,無效的物件名稱 'syssubsystems'。 [SQLSTATE 42S02] (ConnCacheSubsystems)

2024-08-06 12:00:08 - ! [449] 無法列舉子系統 (原因: 無效的物件名稱 'syssubsystems'。 [SQLSTATE 42S02] (錯誤 208))

再安裝CU28也是一樣問題無法啟動。

於是找了另外一台正常的DB查看,確實有syssubsystems這個資料表存在。

直接轉出create語法在有問題的那台DB把資料表建起來,重啟SQL AGENT服務就正常了。

CREATE TABLE [dbo].[syssubsystems](

[subsystem_id] [int] NOT NULL,

[subsystem] [nvarchar](40) NOT NULL,

[description_id] [int] NULL,

[subsystem_dll] [nvarchar](255) NULL,

[agent_exe] [nvarchar](255) NULL,

[start_entry_point] [nvarchar](30) NULL,

[event_entry_point] [nvarchar](30) NULL,

[stop_entry_point] [nvarchar](30) NULL,

[max_worker_threads] [int] NULL

) ON [PRIMARY]

GO

重啟後,這個資料表就會自動長出一些資料。

看了二篇文章似乎都跟msdb有做什麼變動造成的。回想一下為什麼有這個錯,我有改過msdb嗎?? 好像也沒有...

https://www.dbaservices.com.au/the-ssis-subsystem-failed-to-load/

The problem is most likely that the location of your SQL Server installation directory differs from that of the old serve

https://byronhu.wordpress.com/2011/07/04/sql-agent-job-%E6%9A%AB%E5%81%9Csuspend/

因為從原來全部安裝在 C:\ 的 SQL Server 備份 msdb 後,restore 到安裝在 D:\ 的 SQL Server,除要注意 SQL Server 的 Build No 外,若有  Job 呼叫到外部子系統(例如 SSIS、Replication…等),也要一併注意 msdb.dbo.syssubsystems 的設定

二篇都說到執行,但我是連這個資料表都沒有,就直接重建了。
use msdb
go
delete from msdb.dbo.syssubsystems
exec msdb.dbo.sp_verify_subsystems 1
go

和SSL連線有關的設定

HTTPS連線,不管是在寫sql clr或者powershell,每次遇到以下二類SSL錯誤,都忘了要改啥。這次記錄下,以後可以參考。 System.Net.WebException: 基礎連接已關閉: 接收時發生未預期的錯誤。 ---> System.ComponentM...