DataAction / AdoNetCore.AseClient

AdoNetCore.AseClient - a .NET Core DB Provider for SAP ASE
Apache License 2.0
108 stars 45 forks source link

DateTime Parameters Cause Query Execution to Hang Indefinitely #141

Closed pnquest closed 4 years ago

pnquest commented 5 years ago

Describe the bug A Query including 2 DateTime input parameters hangs indefinitely. Removing the parameters from the query and hard-coding test values results in the query returning almost instantly.

To Reproduce Please provide C#/SQL necessary to reproduce the issue, and steps to follow: Sample SQL:

SELECT v1 AS col1,
            v2 As col2,
FROM table
WHERE v2 between @StartDate and @EndDate

Sample C#

using (var connection = new AseConnection(_connectionString))
{
    connection.Open();

    using (AseCommand command = connection.CreateCommand())
    {
        command.CommandText = _pmStartTimeSql;
        AseParameter startDateParam = command.Parameters.Add("@StartDate", AseDbType.DateTime);
        startDateParam.Value = date.Date;
        AseParameter endDateParameter = command.Parameters.Add("@EndDate", AseDbType.DateTime);
         endDateParameter.Value = new DateTime(date.Year, date.Month, date.Day, 23, 59, 59);
         //This is where we hang forever
         using(DbDataReader r = await command.ExecuteReader().ConfigureAwait(false))
         {
             while(await r.ReadAsync().ConfigureAwait(false))
             {
                 //Do stuff here
             }
         }
    }
}

Expected behavior Execution should be successful. (unless I am doing something wrong, in which case an exception should be thrown).

Environment

Additional context The Sybase instance I am connecting to is version 12.5.3.

senseibaka commented 5 years ago

Hi @pnquest we'll have a look at reproducing this, however I should point out that we only aim to support ASE versions 15 and 16.

senseibaka commented 5 years ago

hi @pnquest I've tried to reproduce your issue, but have not succeeded.

Can you review this change and tell me what's missing? I had to make a couple of small changes to your sample to get it to compile/run. https://github.com/DataAction/AdoNetCore.AseClient/commit/9f61f4e6577577a4fb54d29bfd08679cae5491fa

Thanks.