1

我是 Telerik 报告的新手。我一直在尝试关注这篇知识库文章,或多或少。

那里描述的方法绕过了向导。我需要绕过向导,因为数据库是 SQL Server 2000,而向导需要 2005 或更高版本。

我将 sqlDataAdapter 从工具箱拖放到报告中。适配器在报告的构造函数中配置。

当我将文本字段添加到我的报告并转到其属性页面并单击省略号 [...] 按钮以获取值并单击对话框左下角的“字段”时,右侧的窗格显示“没有数据源”。

如何在设计时识别数据源?我错过了什么?谢谢

namespace EventsReportingClassLibrary
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.SqlClient;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;

    /// <summary>
    /// Summary description for Report1.
    /// </summary>
    public partial class Report1 : Telerik.Reporting.Report
    {

        private SqlConnection CNN;

        private SqlDataAdapter DA
        {
            get { return sqlDataAdapter1;  //  dropped from the toolbox onto report}
        }

        private string ConnectionString 
         {
                get { return "server=server5\\SQL2K;Initial Catalog=foo;User Id=foo2;Password=foo3;Pooling=yes"; }   
         }

        public Report1()
        {

            InitializeComponent();


           CNN = new SqlConnection(ConnectionString);          
           DA.SelectCommand = new SqlCommand("select * from myView",CNN);
            DA.SelectCommand.CommandType = CommandType.Text;
            this.DataSource = DA;
        }

        private void Report1_NeedDataSource(object sender, System.EventArgs e)
        {
          // fires at run-time if datasource of this report is null

        }


    }

}
4

0 回答 0