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

Cannot figure out data sources....

3 Answers 188 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Daniel Corbett
Top achievements
Rank 1
Daniel Corbett asked on 10 Mar 2010, 11:35 PM
what is the best way to troubleshoot when your datasource isn't working?

The Fields in the datasource just don't show up when trying to access them.   I need to pull data from an Entity Framework data source.
In the code below, I put everything into a simple class, like your Cars example.

I have created an ObjectDataSource which uses the call to Submissions.GetSubmissions().   I have assigned this datasource to the Report and an embedded list   Everything compiles without errors, but when I try to set a textbox to a field value, I don't see any fields, I just see, "No datasource".

I am using the newly released 2010 version of Telerik Reporting in Visual Studio 2008.

Suggestions?
Is there a walk through that I should be using?

Thanks,
   - Daniel

using System;  
using System.Collections;  
using System.Collections.Generic;  
using System.Configuration;  
using System.Linq;  
using System.Text;  
using DatabaseLayer;  
using log4net;  
 
namespace PCIIReports  
{  
    public class RSubmission  
    {  
        private Guid _submissionID;  
        private string _cikrName;  
        private string _cikrCountry;  
        private string _cikrState;  
 
        public RSubmission() { }  
 
        public RSubmission(Guid submissionId, String cikrName, string cikrCountry, string cikrState)  
        {  
            _submissionID = submissionId;  
            _cikrName = cikrName;  
            _cikrCountry = cikrCountry;  
            _cikrState = cikrState;  
        }  
 
        public Guid SubmissionId  
        {  
            get { return _submissionID; }  
            set { _submissionID = value; }  
        }  
 
        public String CIKRName  
        {  
            get { return _cikrName; }  
            set { _cikrName = value; }  
        }  
 
        public String CIKRCountry  
        {  
            get { return _cikrCountry; }  
            set { _cikrCountry = value; }  
        }  
 
        public String CIKRState  
        {  
            get { return _cikrState; }  
            set { _cikrState = value; }  
        }  
    }  
 
    public class Submissions  
    {  
        private static readonly ILog Log =  
            LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);  
 
        static string GetConnectionStringByName(string name)  
        {  
            // Assume failure.  
            string returnValue = null;  
 
            // Look for the name in the connectionStrings section.  
            ConnectionStringSettings settings =  
                ConfigurationManager.ConnectionStrings[name];  
 
            // If found, return the connection string.  
            if (settings != null)  
                returnValue = settings.ConnectionString;  
 
            return returnValue;  
        }  
 
        public Submissions()  
        {  
        }  
 
        public List<RSubmission> GetSubmissions()  
        {  
            var connectionString = GetConnectionStringByName("pciidbContext");  
 
            var context = new pciidbContext(connectionString);  
 
            var query =  
                from submission in 
                    context.Submissions.Include("Submitter").Include("OnBehalfOf").Include("Documents").ToList()  
                select new RSubmission  
                           {  
                               SubmissionId = submission.SubmissionId,  
                               CIKRName = submission.CriticalInfrastructureKey == null ? "Unknown" : submission.CriticalInfrastructureKey.Name,  
                               CIKRCountry = submission.CIKRCountry,  
                               CIKRState = submission.CIKRStateAbbr  
                           };  
            return query.ToList();  
        }  
    }  
}  
 

3 Answers, 1 is accepted

Sort by
0
Daniel Corbett
Top achievements
Rank 1
answered on 11 Mar 2010, 06:20 PM
Still having issues with this.

I have learned that you can't grab the connection string easily using conventional means, and even using the means telerik recommended didn't seem to work with EntityConnections.  Now my connectionString is embedded in the code..    The code (an entity framework query) works from a unit test, but doesn't work when called from the designer, but I don't see the error message, and I'm not sure the best way for me to get that within the Visual Studio entvironment.

The only error I get is:

  An error has occured while processing Table *:
  Exception has been thrown by the target of an invocation.

Any clues?   I am not even utilizing the data returned by the query, this happens somewhere while trying to receive the query within the visual studio design time environment.

Thanks,

   - Daniel
0
Accepted
Ivan
Telerik team
answered on 12 Mar 2010, 02:04 PM
Hi Daniel Corbett,

The reason you do not see the data source schema is probably because your business logic method throws an exception when it is called during design-time. The Data Explorer tool window suppresses the exception indicating only that there is no data source available at this time. After examining your code it appears that your method fails because ConfigurationManager cannot resolve the connection string correctly in design-time. More on this topic and a possible workaround can be found in the following KB article which discusses how to use connection strings from a configuration file.

Sincerely yours,
Ivan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Adrian Segovia
Top achievements
Rank 1
answered on 24 May 2010, 09:25 PM
Its seems you are having a similar problem.
It turns out that static methods cannot be invoked from your business class (limitation of Telerik Reporting 2010 Q1). I would try making a call without using the static method GetConnectionStringbyName. Wrapping the static method is what I have been suggested to do but I have not figured it out how to wrap a static method yet.

Sincerely

Adrian
Tags
General Discussions
Asked by
Daniel Corbett
Top achievements
Rank 1
Answers by
Daniel Corbett
Top achievements
Rank 1
Ivan
Telerik team
Adrian Segovia
Top achievements
Rank 1
Share this question
or