title: Populate a reportviewer by codebehind
body: <p>Im using reportviewer with <code>strongly dataset</code> but now<br>
   I need to populate my reportviewer via codebehind. But I'm getting this error:<br>
  <code>A data source instance has not been supplied for the data source 'ds_blabla'.</code><br>
  Here's my code to feed the dataset:  </p>
  
  <pre><code>public DataSet PreencheDS(Relatorios rel)
    {
       DataSet retorno = new DataSet();
       try
         {
           string sql = @"SELECT proj.descricao AS projeto, func.descricao AS funcionalidade, clb.clube AS cliente, ch.descricao
           FROM MyTable ch 
           INNER JOIN table1 proj ON MyTable.projeto = table1.id 
           INNER JOIN table2 func ON MyTable.funcionalidade = table2.id 
           INNER JOIN table3 clb ON MyTable.clube = table3 .id
           WHERE (MyTable.responsavel = @responsavel) AND (MyTable.clube = @clube) AND (MyTable.dt_cadastro &gt;= @dt_inicial) AND (MyTable.dt_cadastro &lt;= @dt_final)";                
                  MySqlCommand cmd = new MySqlCommand();
                  cmd.CommandText = sql;
                  cmd.CommandType = CommandType.Text;
                  cmd.Parameters.Add(new MySqlParameter("@responsavel", MySqlDbType.VarChar)).Value = rel.Responsavel_ID;
                  cmd.Parameters.Add(new MySqlParameter("@clube", MySqlDbType.VarChar)).Value = rel.Clube_ID;
                  cmd.Parameters.Add(new MySqlParameter("@dt_inicial", MySqlDbType.DateTime)).Value = rel.Dt_Inicial;
                  cmd.Parameters.Add(new MySqlParameter("@dt_final", MySqlDbType.DateTime)).Value = rel.Dt_Final;
                  retorno = _dal.Consultar(cmd);
              }
              catch (Exception ex)
              {
                  throw new Exception(ex.Message);
              }
              return retorno;
          }  
  </code></pre>
  
  <p>And here's the page that contains my <code>ReportViewer</code>  </p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
      {           
          if (!IsPostBack)
             {
                rel.Responsavel_ID = Convert.ToInt32(Session["usrValue"].ToString());
                rel.Clube_ID = Convert.ToInt32(Session["clube_id"].ToString());
                rel.Dt_Inicial = Session["dt_inicial"].ToString() + " 00:00:00";
                rel.Dt_Final = Session["dt_final"].ToString() + " 23:59:59";
  
                DataSet ds = _rel.PreencheDS(rel);
                ReportDataSource source = new ReportDataSource("MyTable", ds.Tables[0]);              
                this.ReportViewer1.ProcessingMode = ProcessingMode.Local;
                this.ReportViewer1.LocalReport.DataSources.Clear();
                this.ReportViewer1.LocalReport.DataSources.Add(source);
                this.ReportViewer1.LocalReport.Refresh();
              }
          }  
  </code></pre>
  
  <p>I want to do it by <code>codebehind</code> instead of using <code>strongly dataset</code> because I need to pass <code>parameters</code> to my reportviewer. But these <code>parameters</code> they may vary... So I want to do it by <code>codebehind</code>.  </p>
  
  <p><strong>UPDATE</strong><br>
  I did like <a href="https://stackoverflow.com/a/15971652/1919644">this</a>. Now there's no message anymore, but nothing appears...</p>