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

DataSet not binding to Report

4 Answers 311 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Keith
Top achievements
Rank 1
Keith asked on 11 May 2009, 04:12 PM
Hello there---

I have just begun to use the Reporting component and have been successful following the tutorials up to the dynamically binding section... I have been able to create a report that uses data from the database (by way of the TableAdapter... DataSource Wizard) and implement it within an ASP.NET web page, but now that I am trying to bind the report to a DataSet object using the code-behind, the report is no longer populating with data. No errors are thrown, it is just not populating with data. I have verified that the query string used does generate rows by going directly the SQL db and testing the query there.

I am building the DataSet in the constructor of the report and noticed in the documentation that the Preview feature will not populate the report, but even when I run the report within the context of the web app, I still do not see the data for the report. When I set the breakpoint in the constructor of the code-behind, it never hits the breakpoint, so I am not sure how to go about debugging the report itself.

Here is the code that binds the DataSet to the report.

public ProjectListWeb()  
        {  
            /// <summary> 
            /// Required for telerik Reporting designer support  
            /// </summary> 
            InitializeComponent();  
 
            //  
            // TODO: Add any constructor code after InitializeComponent call  
            //  
 
            // TODO: This line of code loads data into the 'projectDataSet.ProjectDataSetTable' table. You can move, or remove it, as needed.  
            try  
            {  
                                 
                _queryStr = @"...";  //query that returns data rows  
 
                SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings[0].ToString());                  
                SqlCommand comm = new SqlCommand(_queryStr, conn);  
                DataSet dsProjects = new DataSet();  
                SqlDataAdapter adp = new SqlDataAdapter(comm);  
                adp.Fill(dsProjects);                  
 
                this.DataSource = dsProjects;  
                this.DataMember = dsProjects.Tables[0].ToString();  
                  
 
            }  
            catch (System.Exception ex)  
            {  
                // An error has occurred while filling the data set. Please check the exception for more information.  
                System.Diagnostics.Debug.WriteLine(ex.Message);  
            }  
        } 

I have also tried just binding directly to the DataAdapter as an alternative (following the tutorial's alternative).

Any help would be great!

Thanks!

---Keith

4 Answers, 1 is accepted

Sort by
0
Keith
Top achievements
Rank 1
answered on 11 May 2009, 06:58 PM
After tinkering some more with this issue, I discovered that the ConnectionString I was using was not working. Since there was no error thrown, I had not initially suspected that piece to be off. I replaced the ConnectionString I was trying to use from the app.config with the ConnectionString from the web.config and it loaded the DataSet just fine.

---Keith
0
John Shahan
Top achievements
Rank 1
answered on 27 Jul 2009, 03:59 PM
I appear to be having an identical issue.  The dataset bound to the report will dsiplay if you preview it in the xsd file but will not preview on the Preview or HTML Preview tab and won't display anything but the header information if I run the web app.  I don't see that I have an app.config file.  Is there another file that might conntain in incorrect connection string?
0
Steve
Telerik team
answered on 30 Jul 2009, 04:05 PM
Hello John,

If you have used the Report Wizard to create the dataset you would have two options:
  • save your connectionString to the web.config by using the "Save the Connection String" dialog, which automatically creates app.config and settings file containing the needed attributes. Then all you need to do is change the connectionString at a single location before deploying your project.
  • if you choose not to save the connectionString in a config file, it would be stored in its default location - in the typed dataset! In that case you would need to alter the connectionString manually through the tableadapter (see screenshot).

Regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
John Shahan
Top achievements
Rank 1
answered on 30 Jul 2009, 04:20 PM
The problem was caused by the dataset itself missing the connection string.  Pasting it from web.config resolved the issue.
Tags
General Discussions
Asked by
Keith
Top achievements
Rank 1
Answers by
Keith
Top achievements
Rank 1
John Shahan
Top achievements
Rank 1
Steve
Telerik team
Share this question
or