SolvedDapper QueryAsync throws "No columns were selected" when stored proc doesn't perform a select statement

Tested on Dapper 1.42 and 1.50.2

The following sql statement will simulate creating a temp stored proc and execute it with dapper

create procedure #TestProcedure
as
begin

    -- basically a failed if statement, so the select is not happening and the stored proc return nothing
    if 1=0
    begin
        select 
            'Password' as ColumnName,
            'Cannot be the same as your username' as [Message]
    end

end

exec #TestProcedure

When using Query version, it works fine and no results return. When using QueryAsync version, it throws "No columns were selected" error.

I attached a code sample using microsoft localdb. The sample project is using Dapper 1.50.2 and structure similar to the one I submitted in #501

DapperBugReplication20160827.zip

19 Answers

✔️Accepted Answer

Nothing on this? This is a real problem.. We have a bunch of procs that throw errors if the sensitive data you queried is not there:

IF @@ROWCOUNT = 0 RAISERROR ('User does not exists', 11, 1)

The database is old, and I'm not going to ask them to change 1000 procs to adjust to my code. multireader should expose some safe reader so we don't get these errors.

Other Answers:

We mixed up issues here a while ago and I just realized that reading back through here. This is fixed for the next release and will be up on MyGet shortly after the next build.

More Issues: