Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

`ClearAndInitialize()` fails when called on the Databases property of a Dynamics CRM server

未關閉
#207 1 則留言 1 個 reaction 已指派 1 人 在 GitHub 檢視

還沒有人認領這個 Issue。

  • #208 來自 @copilot-swe-agent —— 已關閉,未合併

評估

這個 Issue 還沒有評估資料。

描述

bug

This was working in 171.30.0 but has been broken since 172.52.0 (including latest).

Minimal repro:

using Microsoft.Data.SqlClient;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;

SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder("Data Source=org12345678.crm.dynamics.com,1433;User [email protected];Authentication=ActiveDirectoryInteractive");

Server server = new Server(new ServerConnection(new SqlConnection(connectionString.ConnectionString)));
var databases = server.Databases;

try
{
    databases.ClearAndInitialize("[(@IsSystemObject = 0)]", ["Status"]);
    Console.WriteLine("Databases initialized successfully.");
} catch (Exception ex)
{
    Console.WriteLine(ex.Message);
}

Error message:

An exception occurred while executing a Transact-SQL statement or batch.
Inner exception: CREATE TABLE' statement​ is not supported. Line:2, Position:9

Stack trace:

   at Microsoft.SqlServer.Management.Common.ServerConnection.GetExecuteReader(SqlCommand command)
   at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteReader(String sqlCommand, SqlCommand& command)
   at Microsoft.SqlServer.Management.Smo.ExecuteSql.GetDataReader(String query, SqlCommand& command)
   at Microsoft.SqlServer.Management.Smo.DataProvider.SetConnectionAndQuery(ExecuteSql execSql, String query)
   at Microsoft.SqlServer.Management.Smo.ExecuteSql.GetDataProvider(StringCollection query, Object con, StatementBuilder sb, RetriveMode rm)
   at Microsoft.SqlServer.Management.Smo.ExecuteSql.GetDataProvider(StringCollection query, Object con, StatementBuilder sb)
   at Microsoft.SqlServer.Management.Smo.SqlObjectBase.FillData(ResultType resultType, StringCollection sql, Object connectionInfo, StatementBuilder sb)
   at Microsoft.SqlServer.Management.Smo.SqlObjectBase.FillDataWithUseFailure(SqlEnumResult sqlresult, ResultType resultType)
   at Microsoft.SqlServer.Management.Smo.SqlObjectBase.BuildResult(EnumResult result)
   at Microsoft.SqlServer.Management.Smo.DatabaseLevel.GetData(EnumResult res)
   at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData()
   at Microsoft.SqlServer.Management.Sdk.Sfc.Environment.GetData(Request req, Object ci)
   at Microsoft.SqlServer.Management.Sdk.Sfc.Enumerator.GetData(Object connectionInfo, Request request)
   at Microsoft.SqlServer.Management.Smo.ExecutionManager.GetEnumeratorDataReader(Request req)
   at Microsoft.SqlServer.Management.Smo.SqlSmoObject.InitChildLevel(Urn levelFilter, ScriptingPreferences sp, Boolean forScripting, IEnumerable`1 extraFields)
   at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.InitializeChildCollection(Boolean refresh, ScriptingPreferences sp, String filterQuery, IEnumerable`1 extraFields)
   at Microsoft.SqlServer.Management.Smo.SmoCollectionBase.ClearAndInitialize(String filterQuery, IEnumerable`1 extraFields)
   at Program.<Main>$(String[] args)
主要語言
C#
星號
143
分支
29
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/sqlmanagementobjects 的其他 Issue

查看 microsoft/sqlmanagementobjects 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。