共用方式為


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 System.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();
    }
}
Imports System.Data.SqlClient
Module Module1
    Sub Main()
        Dim builder As 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()
    End Sub
End Module

備註

此屬性會對應至連接字串內的 "MultipleActiveResultSets" 索引鍵。

適用於

另請參閱