2
Answers

Not all code paths return a value

Photo of A Repasky

A Repasky

13y
2.7k
1
I have the following method. 

      public static DebOop AddToDict(string rc, string memberNbr, string person, string group, string subGroup         , string plancode, iDB2DataReader dr

     {

         DebOop returnvalue = null;

         DebOop record = new DebOop();

         //Main data

         record.SubscriberNumber = dr.GetiDB2Char(0);

         record.PersonNumber = dr.GetiDB2Char(1);

         record.GroupID = dr.GetiDB2Char(2);

         record.Subgroup = dr.GetiDB2Char(3);

         record.Plancode = dr.GetiDB2Char(4);

  . . . . . skipped many records that do the same . . . . . . .

         record.FamDoaOutNetRM = dr.GetiDB2Decimal(85);

         record.returnCode = rc;

         //Finished record 

         returnvalue = record;         

      }

I get the following error:

Error 1 'DedOopData.DebOop.AddToDict(string, string, string, string, string, string, IBM.Data.DB2.iSeries.iDB2DataReader)': not all code paths return a value C:\DedOopData\DedOopData\DebOop.cs 125 28 DedOopData

There is only one path.  So why am I getting the error?  Is this the best way to pass back the Class record?

Thanks,

Arep


Answers (2)

0
Photo of Ankit Sharma
NA 8.8k 141k 7y
Hi Anoop,
 
Please try this SQL and let me know if it works for you
 
  1. declare @storeid bigint    
  2. set @storeid=19    
  3. select  I.NameOfStores, I.ReferenceNo, SUM(Inwards.InwardQty) InwardQty,  SUM(ISNULL(Issued.IssuedQty,0)) IssuedQty, SUM((ISNULL(Inwards.InwardQty,0)-ISNULL(Issued.IssuedQty,0)))as Balance    
  4. from InventoryInwards as I     
  5. LEFT JOIN    
  6.         (select ReferenceNo,  nameofStores, ISNULL(Sum(ISNULL(Qty,0)),0) as InwardQty    
  7.         from InventoryInwards where StoreID=@storeid  
  8.         group By NameOfStores, ReferenceNo, Unit) as Inwards ON I.NameOfStores = Inwards.NameOfStores    
  9.         and i.ReferenceNo=Inwards.ReferenceNo  
  10.          
  11. left JOIN    
  12.         (select   nameofStores, ISNULL(Sum(ISNULL(Qty,0)),0) as IssuedQty    
  13.         from InventoryIssued where StoreID=@storeid    
  14.         group By NameOfStores, ReferenceNo, unit) as Issued on I.NameOfStores= Issued.NameOfStores    
  15.         
  16.           
  17.     
  18. where i.StoreID = @storeid    
  19. group by I.NameOfStores, I.ReferenceNo, I.Unit   
Accepted
0
Photo of Anoop Bansal
NA 58 2.2k 7y
Thanks Ankit... that was I missing out.