1

我已经在我的 PC 中安装了 Sql Server Management Studio。

然后远程连接到我的一个数据库

我执行一个查询,该查询在近 1 或 2 秒内返回 6000 条记录, 但是当我从 .Net 应用程序(WPF 桌面)也从同一台 PC 运行相同的查询时,数据传输几乎需要 8-9 秒

我在 .Net 中的代码非常简单明了

这是代码

 Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
    Dim Sql_Connection As New SqlClient.SqlConnection("MyRemoteSQLConnectionString")
    Dim Sql_Command As New SqlClient.SqlCommand("select Col1,Col2,Col3,Col4,Col5,Col6 from Table", Sql_Connection)
    Sql_Connection.Open()
    dr = Sql_Command.ExecuteReader

    Dim DataTable As New DataTable
    DataTable.Load(dr)
    'The above code takes 8-9 seconds to finished but in ssmo takes only 1-2 seconds for 6000 Records
    Sql_Connection.Close()

End Sub

为什么会这样?剂量 ssms 有不同的方式来管理传输的数据?

4

1 回答 1

1

好的,看来我在这篇文章中找到了答案

从 ADO.NET 与 SMSS 相比,具有相同查询计划的相同查询需要大约 10 倍的时间

ado.net ConnectionString 中的 MultipleActiveResultsSet 选项应为FALSE

和@DanGuzman 感谢您清除此问题。“SSMS 也使用 ADO.NET。”

于 2017-12-24T10:29:42.770 回答