This is a migrated thread and some comments may be shown as answers.

Issues adding EntityDataSource to Report

1 Answer 175 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 18 May 2011, 05:51 PM
I am experiencing issues while trying to add a EntityDataSource to a report:

Method 1:
1) Opened a new VS2010 project of "Class Library"
2) Added a new "Telerik Report Q1 2011" item to the project, and cancelled the Report Wizard
3) Added a new EntityDataSource from the toolbox
    a) On the "Choose Your Data Connection" screen, selected "Specifiy a new connection string" and added the following to connect to a simple database on my local installation of SQL 2008: (See attached picture "ConnectionString")
metadata=res://*/SL_Lab1.csdl|res://*/SL_Lab1.ssdl|res://*/SL_Lab1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SL_Lab1;Integrated Security=True"
    b) Proceed to the "Save the Connection String" page, leaving the "Yes, save this connection string..." checkbox checked, I click "Next" and receive a "blank" VS2010 error. (See attachment "SaveError")

Method 2:
1) I cancel the wizard and remove the EntityDataSource item from the report
2) I add an ADO.NET Entity Model to the project - named "SL_Lab1" to match the database name.
3) I add a blank table "table1" into the body of the report.
4) I switch over to the code view and update the code behind.
namespace EntitySetTest
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;
    using Telerik.Reporting;
    using Telerik.Reporting.Drawing;
  
    /// <summary>
    /// Summary description for EntitySetReport.
    /// </summary>
    public partial class EntitySetReport : Telerik.Reporting.Report
    {
        public EntitySetReport()
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
  
            Telerik.Reporting.EntityDataSource entityDataSource = new Telerik.Reporting.EntityDataSource();
  
            entityDataSource.ObjectContext = typeof(SL_Lab1Entities);
  
            Telerik.Reporting.Report report = new Telerik.Reporting.Report();
  
            report.DataSource = entityDataSource;
  
            table1.DataSource = entityDataSource;
        }
    }
}
5) Previewing the report gives me "The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid."
6) Add in the connection string
entityDataSource.ConnectionString = "SL_Lab1Entites";
6) Build and Preview - same error.
7) Change ConnectionString to:
entityDataSource.ConnectionString = "metadata=res://*/SL_Lab1.csdl|res://*/SL_Lab1.ssdl|res://*/SL_Lab1.msl;provider=System.Data.SqlClient;provider connection string="Data Source=localhost;Initial Catalog=SL_Lab1;Integrated Security=True;MultipleActiveResultSets=True"";
8) Build and Preview - same error.

I have tried this several times, with different databases and always receive an error.  Either the one above or "Unable to load the specified metadata resource".

Any advice on what I am doing wrong?




1 Answer, 1 is accepted

Sort by
0
Robert
Top achievements
Rank 1
answered on 18 May 2011, 06:47 PM
OK - I realize I missed adding the "entityDataSource.ObjectContextMember" into the example above.


I created a partial class with "GetArtists" defined, removved the code behind, and was able to add an EntityDataSource, table and fields to my report through the designer.
Tags
General Discussions
Asked by
Robert
Top achievements
Rank 1
Answers by
Robert
Top achievements
Rank 1
Share this question
or