title: Error message: cannot find table 0
body: <p>First I would like to apologise for the length of this post. But I want you to understand the entire issue.</p>
  
  <p>I have to merge three datasets (<code>dsGetForm</code>, <code>dsmedication_details</code> and <code>dsbroadband_details</code>), and show the result in a table. </p>
  
  <p>Sometimes <code>dsbroadband_details</code> contains rows and sometimes it doesn't. </p>
  
  <p>This is what I am using right now to merge the datasets.</p>
  
  <pre><code>if (dsGetForm != null &amp;&amp; dsmedication_details != null &amp;&amp; dsbroadband_details != null)
  {
     dsGetForm.Tables[0].Merge(dsmedication_details.Tables[0]);
     dsGetForm.Tables[0].Merge(dsbroadband_details.Tables[0]);
  }
  else if (dsGetForm == null &amp;&amp; dsmedication_details != null)
  {
     dsGetForm = dsmedication_details;
  }
  else if (dsGetForm == null &amp;&amp; dsbroadband_details != null )
  {
     dsGetForm = dsbroadband_details;
  } 
  </code></pre>
  
  <p>The problem is that, the stored procedure (SP) which is used to fill the dataset <code>dsbroadband_details</code> is giving me this error message when the result of stored procedure is null</p>
  
  <blockquote>
    <p>Error message: Cannot find table 0. 
    Description: An unhandled exception
    occurred during the execution of the
    current web request. Please review the
    stack trace for more information 
    about the error and where it
    originated in the code. </p>
    
    <p>Exception Details:
    System.ServiceModel.FaultException`1[[System.ServiceModel.ExceptionDetail,
    System.ServiceModel, Version=3.0.0.0,
    Culture=neutral, 
    PublicKeyToken=b77a5c561934e089]]:
    Cannot find table 0</p>
  </blockquote>
  
  <p>This is my stored procedure</p>
  
  <pre><code>Alter Procedure dbo.OEA_SP_GET_BROADBAND ( 
                  @appid    NUMERIC,
                  @clientid NUMERIC,
                  @Lang Varchar(10))
  AS 
     SET nocount  ON 
     BEGIN 
    declare @PIName as varchar(100)
    declare @username as varchar(20)
    declare @pform_id as varchar(20)
    declare @pform_desc as varchar(100)
    declare @userid varchar(20)
    declare @msn tinyint
  
    set @PIName=''
    if exists(SELECT app_id from ext_well_new_programs (nolock) where app_id=@appid and new_prog_id='BB' and status='A')
    begin
        select @PIName=dbo.oea_fn_fetch_fullname(@appid,primary_msn,1,@lang,@clientID) 
            from app_application with (nolock)
        where app_id = @appid
    end 
  
    if @PIName &lt;&gt; ''
    begin
      select Distinct @username = dbo.oea_fn_fetch_caaname(prog.last_update_id, 30000) 
              from app_prog_submission prog (nolock) 
              where app_id = @appid
  
              select @userid = user_id, @msn = primary_msn 
              from app_application (nolock) 
              where app_id = @appid
  
              set @pform_id = 'learnmore'
      set @pform_desc = 'Cash Back for Broadband at Home'
  
      select @PIName as mem_name, @appid as app_id, @username as username, @pform_id as pform_id, @pform_desc as pform_desc, 0 as noncust, @userid as userid, @msn as msn
   END
       End
  </code></pre>
  
  <p>I think, I need to add a <code>else</code> condition after <code>if @PIName &lt;&gt; ''</code> condition. </p>
  
  <p>My question is what should that else condition be?  </p>
  
  <p>Since I only need the values of the select statement (at the end) of the <code>if @PIName &lt;&gt; ''</code>
  condition when this condition is true, I am a bit confused what else that should be?</p>
  
  <p>Any help is much appreciated.</p>