>我有执行数据库过程的C#应用程序。我可以成功地从这些过程中获得结果,但 SQL Server 事件探查器显示"sp_reset_connection"而不是过程名称。我在 SQL Server 事件探查器中将事件筛选器设置为"存储过程"。在列中,我有"对象名称"和"文本数据",当我从应用程序执行存储过程时,它们都显示"sp_reset_connection"。
C# 代码(变体代码等于 smth,如"exec dbo.sp_name_1"(:
public string ExecSpReturnTime(string connectionString, string code)
{
long execTime = 0;
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.StatisticsEnabled = true;
connection.Open();
using (SqlCommand command = new SqlCommand(code, connection))
{
command.ExecuteNonQuery();
}
var stats = connection.RetrieveStatistics();
execTime = (long)stats["ExecutionTime"];
}
return execTime.ToString();
}
我在 SQL 事件探查器"存储过程 -> SP:已编译"中添加了筛选器,现在我可以看到我的过程。谢谢,Damien_The_Unbeliever!