-1

我写了这段代码:

namespace ImportarAlamo
{
    public partial class RelIndi : Form
    {
        public RelIndi()
        {
            InitializeComponent();
        }

        private void RelIndi_Load(object sender, EventArgs e)
        {
            reportViewer1.Visible = false;
        }

    private void button1_Click(object sender, EventArgs e)
    {
        reportViewer1.Visible = true;
        reportViewer1.Reset();
        fillrel();

        // Here is the part to populate the report :
        ReportDataSource DS = new ReportDataSource("individual2",fillrel());
        reportViewer1.LocalReport.DataSources.Clear();
        reportViewer1.LocalReport.ReportPath = @"C:\relatorios\Report8.rdlc";
        reportViewer1.LocalReport.DataSources.Add(DS); 
        reportViewer1.LocalReport.Refresh(); 

    }

    public DataSet fillrel()
    {
        DataSet uny = new DataSet();

        SqlConnection abre = Tconex.GetConnection();
        SqlDataAdapter da2 = new SqlDataAdapter();
        SqlCommand llena = new SqlCommand("rel_Noparam", abre);
        llena.CommandType = CommandType.StoredProcedure;
        da2.SelectCommand = llena;
        da2.Fill(uny,"rel");
        abre.Close();
        return uny;
    }

report8.rdlc 什么都没有,现在代码没有错误,但是我可以在报告上放一个 tablix,我如何显示字段???

4

1 回答 1

0

您忘记将数据源添加到集合中:

ReportDataSource DS = new ReportDataSource("individual2",fillrel());
reportViewer1.LocalReport.DataSources.Clear();
reportViewer1.LocalReport.DataSources.Add(DS);
于 2013-03-21T15:05:36.717 回答