1

I am using SP in C# project to retrieve the output using SqlDataReader. Below is the code.

enter image description here

It is very Simple SP with the select statement. SP return the output when executed from SQL 2014 but when implemented in the above method it doesn't return any output. Both of them has same parameters and DB pointing to the correct server and DB Below is the screen for reference.

Screen shot of SP It is returning count 43. But in the code it is empty.

Kindly help.

pankaj bawdane
  • 101
  • 4
  • 18
  • Possible duplicate of [SQL OUTPUT Stored Procedures not working with ExecuteReader](https://stackoverflow.com/questions/6374193/sql-output-stored-procedures-not-working-with-executereader) – sɐunıɔןɐqɐp Jul 04 '18 at 09:11
  • 1
    Please edit your question and post the source code as text. Please NEVER post source code in images. See: [How to create a Minimal, Complete, and Verifiable Example](https://stackoverflow.com/help/mcve). – sɐunıɔןɐqɐp Jul 04 '18 at 09:13
  • 1
    [You already asked this same question](https://stackoverflow.com/questions/51167794/sp-giving-output-but-sqldatareader-not). Please don't do that as it causes duplicate effort for all parties involved. – Dan Guzman Jul 04 '18 at 10:11

1 Answers1

0

Why not use SqlDataReader instead of SqlDataAdapter?

using(SqlDataReader reader = _oCmd.ExecuteReader())
{
    DataTable dataTable = new DataTable();
    dataTable.Load(reader);

    objLMT = ConvertTo<LMTUsage>(dataTable);
}
João Martins
  • 122
  • 2
  • 8