|
From: dbuchanan on 24 Jun 2008 17:57 I am populating my ReportViewer using a configured SqlDataSource. Is there any way to detect if the results of the query inside this SqlDataSource returns an empty set so that I can send a message to the user. Or does the ReportViewer have a way to inform thie user of an emty data set? Thanks, Doug
From: "Charles Wang [MSFT]" on 25 Jun 2008 03:06 Hi Doug, Tough I am not an ASP.NET expert, I think that I can provide some suggestions for judging if the result set from SqlDataSource is empty. You may refer to the following code: ==================================================== //sqlDs is a SqlDataSource object sqlDs.SelectParameters["id"].DefaultValue = "2,3,4"; DataView dv = sqlDs.Select(DataSourceSelectArguments.Empty) as DataView; //Judge if the returned result is empty if (dv != null && dv.Count>0) { foreach (DataRow row in dv.Table.Rows) { Response.Write(row[0].ToString()); } } else {...} ==================================================== However if possible, I recommended that you use ObjectDataSource for ReportViewer control. For more information, please refer to: Walkthrough: Using a Database Data Source with the ReportViewer Web Server Control in Local Processing Mode http://msdn.microsoft.com/en-us/library/ms252123(VS.80).aspx Creating Data Sources for a ReportViewer Report http://msdn.microsoft.com/en-us/library/ms252094(VS.80).aspx We can find the following description from the second article: "When you are designing a Web page, the Toolbox Data section lists several data source controls like SqlDataSource and XmlDataSource. Some data source controls provide support for Page memory in Web pages and others use shared data. Reports do not use Page memory, so the best choice for a ReportViewer Web server control is to use the ObjectDataSource control. " Anyway if you would like to use SqlDataSource for your ReportViewer, you can try my following code: ===================================================== ReportDataSource rds = new ReportDataSource(); sqlDs.SelectParameters["id"].DefaultValue = "2,3,4"; DataView dv = sqlDs.Select(DataSourceSelectArguments.Empty) as DataView; if (dv != null && dv.Count > 0) { DataSet1 ds = new DataSet1(); ds.T1.Merge(dv.Table); rds.Name = "DataSet1_T1"; rds.Value = ds.T1; this.ReportViewer1.LocalReport.DataSources.Add(rds); this.ReportViewer1.LocalReport.Refresh(); } ===================================================== Hope this helps. If you have any other questions or concerns, please feel free to let me know. Have a nice day! Best regards, Charles Wang Microsoft Online Community Support =========================================================== Delighting our customers is our #1 priority. We welcome your comments and suggestions about how we can improve the support we provide to you. Please feel free to let my manager know what you think of the level of service provided. You can send feedback directly to my manager at: msdnmg(a)microsoft.com. =========================================================== Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications. Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx. ============================================================ This posting is provided "AS IS" with no warranties, and confers no rights. =========================================================
|
Pages: 1 Prev: Bruce L-C / Charles Wang - can you'll help with these issues? Next: SSAS 05 Cube Excel Errors |