C# 在执行存储过程时,成功完成的命令将显示为网格,而不是结果

C# 在执行存储过程时,成功完成的命令将显示为网格,而不是结果,c#,sql,C#,Sql,在执行存储过程时,成功完成的命令将显示为网格,而不是结果。它应该给我看一些数据 Alter PROCEDURE [dbo].[LogReport] @dtFromDateTime datetime, @dtToDateTime datetime AS BEGIN if (@dtFromDateTime!=null and @dtToDateTime!=null) begin select EncryptionLogID,concat(FirstName,' ',LastName) as

在执行存储过程时,成功完成的命令将显示为网格,而不是结果。它应该给我看一些数据

Alter PROCEDURE [dbo].[LogReport]
@dtFromDateTime datetime,
@dtToDateTime datetime
AS
BEGIN
if (@dtFromDateTime!=null and @dtToDateTime!=null)
begin
    select EncryptionLogID,concat(FirstName,' ',LastName) as Username, ClientName,ProjectName,Purpose,Type,StringToConvert,InsertDateTime
    from EncryptionLogs
    inner join Users on Users.UserId=EncryptionLogs.UserID
    where cast(InsertDateTime as date) between cast(@dtFromDatetime as date) and cast(@dtToDateTime as date)
end
else if (@dtFromDateTime=null and @dtToDateTime!=null)
begin
    select EncryptionLogID,concat(FirstName,' ',LastName) as Username, ClientName,ProjectName,Purpose,Type,StringToConvert,InsertDateTime
    from EncryptionLogs
    inner join Users on Users.UserId=EncryptionLogs.UserID
    where cast(InsertDateTime as date)=cast(@dtToDateTime as date)
end
END
go
所以当我使用EXEC LogReport'value1','value2'
注意:是的,有时我必须通过过滤器将日期传递为空(从日期和截止日期)

您有输入错误。您没有使用
=null
!=空
。正确的运算符是
为空
不为空
。我认为这是一个排印错误并投票关闭。在SQL中,NULL意味着未知,所有与未知值的比较产生唯一的逻辑结果-未知。这意味着这两个条件都失败,并且没有执行任何查询。是的,现在它工作正常。非常有用…感谢Gordon提供的完美解决方案和Panagiotis提供的知识