連接配接sql時提示以下内容
SQL Server 阻止了對元件 'Ad Hoc Distributed Queries' 的 STATEMENT'OpenRowset/OpenDatasource' 的通路,因為此元件已作為此伺服器安全配置的一部分而被關閉。系統管理者可以通過使用 sp_configure 啟用 'Ad Hoc Distributed Queries'。有關啟用 'Ad Hoc Distributed Queries' 的詳細資訊,請參閱 SQL Server 聯機叢書中的 "外圍應用配置器"。
看錯誤提示就知道是因為SQL Server的Ad Hoc Distributed Queries元件被禁用了,這裡我用的SQL Server版本是2005,隻需要開啟Ad Hoc Distributed Queries就可以了,方法如下:
1.開啟Ad Hoc Distributed Queries元件,在sql查詢編輯器中執行如下語句:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
2.關閉Ad Hoc Distributed Queries元件,在sql查詢編輯器中執行如下語句:
exec sp_configure 'Ad Hoc Distributed Queries',0
exec sp_configure 'show advanced options',0