共用方式為


SqlConnectionStringBuilder.MultipleActiveResultSets 屬性

定義

為 true 時,應用程式可以維護 Multiple Active Result Sets(MARS)。 為 false 時,應用程式必須處理或取消一個批次處理的所有結果集,才能在該連接上執行任何其他批次處理。 如需詳細資訊,請參閱 Multiple Active Result Sets (MARS)

public:
 property bool MultipleActiveResultSets { bool get(); void set(bool value); };
public bool MultipleActiveResultSets { get; set; }
member this.MultipleActiveResultSets : bool with get, set
Public Property MultipleActiveResultSets As Boolean

屬性值

MultipleActiveResultSets 屬性的值,如未提供任何值,則為 false

範例

下列範例會明確啟用 [多重作用中結果集] 功能。

using Microsoft.Data.SqlClient;

class Program
{
    static void Main()
    {
        SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder();
        builder.DataSource = "(local)";
        builder.IntegratedSecurity = true;
        builder.InitialCatalog = "AdventureWorks";

        // The connection does not allow multiple active result sets
        // by default, so this line of code explicitly
        // enables this feature. Note that this feature is 
        // only available when programming against SQL Server 2005
        // or later.
        builder.MultipleActiveResultSets = true;

        Console.WriteLine(builder.ConnectionString);
        Console.WriteLine();

        Console.WriteLine("Press Enter to continue.");
        Console.ReadLine();
    }
}

備註

此屬性會對應至連接字串內的「多個作用中結果集」索引鍵。

適用於