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

Report Previews But Won't Run

4 Answers 133 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Lynn
Top achievements
Rank 2
Lynn asked on 29 Apr 2010, 03:11 AM
I am using the Reporting tutorial and am having a problem after creating the first two steps in the solution.  The example uses the Adventureworks SQL database.  I have created a Class Library that contains a Telerik Report.  It previews just fine and contains the full data from the database.

Then I created a VB Windows App as part of the solution with a Telerik ReportViewer to view this sample report.  Everything setup the way the tutorial showed, but when I ran the solution (the Windows App is the startup project), I receive a long red, error message about not being able to connect to the database.  See the attached file named reportquestion1.gif .

The VIsual Studio 2010 window is captured in reportlquestion2.gif .

Why does the report preview just fine with the data from the database, but then will not run when part of the whole solution?  The same connection string is in the report definition.  So why can't it make the connection?

Thanks in advance!

4 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 04 May 2010, 06:16 PM
Hello Lynn,

In order for the report to connect to the data in your actual application, you must ensure that the same connectionString is present in the app.config file of your win forms app.

You should copy that connection string from the class library configuration file to your application configuration file (app.config for windows forms app).

More information on this topic is available in this KB article: Using connectionStrings from configuration file.

Kind regards,
Peter
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
Lynn
Top achievements
Rank 2
answered on 08 Jun 2010, 03:03 PM
Putting information such as connect strings in config files does not meet my needs.  In all of my applications, I must change the connect string at run-time depending upon the environment at the time of execution.  There are a number of SQL databases that I must connect to depending upon the client account, etc.

Requiring the connect string to be coded in a config file is not a "feature", it is an impediment to reality.
0
Accepted
Steve
Telerik team
answered on 09 Jun 2010, 08:30 AM
Hi Lynn,

Actually we're not forcing you to save your connectionStrings into the application settings and you make that choice when you're in the "Save ConnectionString" step of the SqlDataSource Wizard. If you uncheck the respective checkbox, the connectionString would be serialized in the InitializeComponent() method e.g.:

//
            // sqlDataSource1
            //
            this.sqlDataSource1.ConnectionString = "Data Source=localhost\\sqlexpress;Initial Catalog=AdventureWorks;Integrated Securi" +
                "ty=True";
            this.sqlDataSource1.Name = "sqlDataSource1";
            this.sqlDataSource1.ProviderName = "System.Data.SqlClient";
            this.sqlDataSource1.SelectCommand = "SELECT        ProductID, Name, ProductNumber\r\nFROM            Production.Product";

You can alter that code, set it in the report constructor or even set it from the actual application prior showing the report. As described in MSDN,  the ConfigurationManager.ConnectionStrings property "gets the ConnectionStringsSection data for the current application's default configuration".
We do not impose any restrictions on that as long as the correct connectionString is present in the current application's default configuration.
More information is present in the Using connectionStrings from configuration file KB article.

Best wishes,
Steve
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
Lynn
Top achievements
Rank 2
answered on 10 Jun 2010, 05:48 AM
Steve,

I marked your response as an answer, but it really isn't.  I marked it as an answer so it would close the item in your system. There's just too much "fluff" like this to work through.  I should be able to set a simple property through code when the report runs based on user or other control information (which would direct me to a specific database for the user running the report).

To be quite honest, I don't even understand half of what you wrote -- and I've been doing this for 30+ years, including several years with Telerik products.  This is just too complicated to have any value for me.
Tags
General Discussions
Asked by
Lynn
Top achievements
Rank 2
Answers by
Peter
Telerik team
Lynn
Top achievements
Rank 2
Steve
Telerik team
Share this question
or