Query with parameter causing timeout

2

I have a query that when executed with ADO.NET takes less than a second to return your data. When adding parameters to this query, the return remains the same.

However, when adding a parameter of type datetime , the query does not execute, giving timeout error.

The parameter is being defined as the code below;

var dataInicioparameter = command.CreateParameter();
dataInicioparameter.ParameterName = "@dataInicio";
dataInicioparameter.Value = dataInicio;
dataInicioparameter.DbType = DbType.DateTime;
command.Parameters.Add(dataInicioparameter);

Inquiry

SELECT * FROM 
        (SELECT *, ROW_NUMBER() OVER (ORDER BY chave) AS RowNumber1 FROM TabelaX 
               WHERE DataUltimaAtualizacao >= @dataInicio AND DataUltimaAtualizacao <= @dataFim) AS TabelaY
               WHERE RowNumber1 > (@rows * 1000) AND RowNumber1 <=  ((@rows * 1000) + 1000)
    
asked by anonymous 08.03.2016 / 15:05

1 answer

0

Try to use SqlDbType.DateTime instead of DbType.DateTime .

var dataInicioparameter = new SqlParameter("@dataInicio", SqlDbType.DateTime) 
{ 
    Value = dataInicio;                              
};

command.Parameters.Add(dataInicioparameter);

Enjoy and look at this link which explains what might be causing this error.

    
31.01.2017 / 20:18