Bucle against TableDataSource?

Hello,

I'm trying this code:
private void _StartReport(object sender, EventArgs e)
    {
      param = Report.GetParameterValue("Param") as string;
     
            
      dataInici =  ((string)Report.GetParameterValue("dataInici")) as string;
      dataFi =   ((string)Report.GetParameterValue("dataFi")) as string;

      
      TableDataSource table = Report.GetDataSource("Consulta") as TableDataSource;
      table.SelectCommand =  "select alarmas_red.id, alarmas_red.texto, alarmas_red.activacion, alarmas_red.ack, seccionadoras.codigo, seccionadoras.descripcion"; 
      table.SelectCommand += " from seccionadoras inner join alarmas_red on seccionadoras.codigo = alarmas_red.idorigen";
      table.SelectCommand += " and origen=10";
      table.SelectCommand += " where " + (string)param + " and activacion >= '" + dataInici + "' and activacion <= '" + dataFi + "'";
      table.SelectCommand += "  order by id";
      
      
      //Traduir
      TableDataSource tTra = Report.GetDataSource("Traduccio") as TableDataSource;
              
      MessageBox.Show(  tTra.Table.Rows.Count.ToString());

      // for (int x=0;x < tTra.Table.Rows.Count ;x++)
       //{
      //   if(tTra.Table.Rows[x][3].ToString() == "inf_DetallAlarma")
       //  {
         //  Memo6.Text = tTra.Table.Rows[x].ToString()+"sip"; 
        // }
      // }
    }
  }

But when I run the form I got this excepcion:

at FastReport.ReportScript._StartReport(Object sender, EventArgs e)
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at TXNYtDib8bZVSvmJMS.u5JqNkoH91ruC1D1Ma.vkQSZaGrP(Object[] )
at Zx3Su48hkBOeZObMVS.aFFNWtBP2tw0dEowd0.NZBsu6gf6(String , Object[] )
at FastReport.Report.InvokeEvent(String name, Object[] parms)
at FastReport.Report.OnStartReport(EventArgs e)
at FastReport.Engine.ReportEngine.kBIG8W38n(Boolean , Boolean , ReportPage )
at FastReport.Engine.ReportEngine.JmlNd4Rvw(Boolean , Boolean )
at FastReport.Report.Prepare(Boolean append)
at FastReport.Report.Prepare()
at d4YS7nysRKNXMdSbTY2.Mjkvc6yk9jmh6OYi3Bb.FM4VPNsIo()


It seems that there isn't any problem with de query. In the preview data it return 1 row.
The problem ocurrs in MessageBox.Show( tTra.Table.Rows.Count.ToString());

It would be a bug?.

Thank you.

Comments

  • edited 10:19AM
    Hello,

    You have to init the datasource:
    ...
    tTra.Init();
    MessageBox.Show( tTra.Table.Rows.Count.ToString());
    ...
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.