Help getting started
In the Visual Web Developer, I can create and run a report using the smart tag as long as it does not include any data (text labels only). I can also run a report with data if it is created originally outside of the VWD environment and references the data directly using a fixed path and connection string. However when using data from a datasource defined within the webpage IE SQLDATASOURCE1, it will not run and throws an error that says "Object reference not set to an instance of an object. ". It does not say which object its referring to but I assume it means the sqldatasource. What am I missing? The sqldatasource does in fact work OK with other controls on the form. I have tried it with both of the techniques outlined as "in a web form" and "in the FRX file" on page 27 of the programmers guide.
Thanks
Thanks
Comments
Here is what I did and it works:
- add SqlDataSource on a web page, configure it;
- add WebReport component
- click smart tag and select our data source;
- click "Design Report";
- create simple list report;
- close the designer;
- save all changes in a project;
- run it and see the prepared report.
If you have a simple demo that demonstrates the problem, please send it to tz@fast-report.com.
<!--
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:maillist %>"
ProviderName="<%$ ConnectionStrings:maillist.ProviderName %>"
SelectCommand="SELECT list_id, name, owner FROM list_definitions ORDER BY name">
</asp:SqlDataSource>
<cc1:WebReport ID="WebReport1"
runat="server"
ReportDataSources="SqlDataSource1"
ReportFile="~/App_Data/testreportinside.frx"
/>
-->
And here is the report.
<?xml version="1.0" encoding="utf-8"?>
<Report ScriptLanguage="Vb" ReportInfo.Created="05/29/2009 13:05:41" ReportInfo.Modified="06/01/2009 10:33:41" ReportInfo.CreatorVersion="1.1.1.0">
<scriptText>Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Drawing
Imports Microsoft.VisualBasic
Imports FastReport
Imports FastReport.Data
Imports FastReport.Dialog
Imports FastReport.Table
Imports FastReport.Barcode
Imports FastReport.Utils
Namespace FastReport
Public Class ReportScript
End Class
End Namespace
</ScriptText>
<Dictionary>
<ViewDataSource Name="SqlDataSource1" ReferenceName="SqlDataSource1" Enabled="true">
<Column Name="list_id" DataType="System.Int32"/>
<Column Name="name" DataType="System.String"/>
<Column Name="owner" DataType="System.String"/>
</ViewDataSource>
</Dictionary>
<ReportPage Name="Page1">
<ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/>
<PageHeaderBand Name="PageHeader1" Top="41.8" Width="718.2" Height="28.35">
<TextObject Name="Text2" Left="56.7" Width="94.5" Height="18.9" Text="list_id"/>
<TextObject Name="Text4" Left="189" Width="94.5" Height="18.9" Text="name"/>
<TextObject Name="Text6" Left="500.85" Width="94.5" Height="18.9" Text="owner"/>
</PageHeaderBand>
<DataBand Name="Data1" Top="74.15" Width="718.2" Height="75.6" DataSource="SqlDataSource1">
<TextObject Name="Text1" Left="56.7" Top="18.9" Width="94.5" Height="18.9" Text="[SqlDataSource1.list_id]"/>
<TextObject Name="Text3" Left="189" Top="18.9" Width="292.95" Height="18.9" Text="[SqlDataSource1.name]"/>
<TextObject Name="Text5" Left="500.85" Top="18.9" Width="132.3" Height="18.9" Text="[SqlDataSource1.owner]"/>
</DataBand>
<PageFooterBand Name="PageFooter1" Top="153.75" Width="718.2" Height="18.9"/>
</ReportPage>
</Report>
And here is the connection string from the webconfig. Note that I'm using a VFP database.
<add name="maillist" connectionString="Provider=VFPOLEDB.1;Data Source=c:\inetpub\wwwroot\maillist\app_data\maillist.dbc" providerName="System.Data.OleDb"/>
The newer version produces an error that says 'Webreport' is ambiguous in the Namespace 'FastReport.Web'.
This is a syntax error in the markup.
'Object reference not set to an instance of an object. '
<!--
<%@ Page Language="VB" %>
<%@ Register Assembly="FastReport"
Namespace="FastReport.Web"
TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:maillist %>"
ProviderName="<%$ ConnectionStrings:maillist.ProviderName %>"
SelectCommand="SELECT list_id, name, owner FROM list_definitions ORDER BY name">
</asp:SqlDataSource>
<h2>FAST REPORT TEST PAGE</h2>
<cc1:WebReport ID="WebReport1"
runat="server"
ReportDataSources="SqlDataSource1"
ReportFile="~/app_data/testreportinside.frx" />
</div>
</form>
</body>
</html>
-->
And this actually works except that I only get the first record from the data in the report.
Regarding your last post - please check that "Data" band in the report is connected to data source.
Server Error in '/MailList' Application.
Control 'WebReport1_ctl05' of type 'DropDownList' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'WebReport1_ctl05' of type 'DropDownList' must be placed inside a form tag with runat=server.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): Control 'WebReport1_ctl05' of type 'DropDownList' must be placed inside a form tag with runat=server.]
System.Web.UI.Page.VerifyRenderingInServerForm(Control control) +8689747
System.Web.UI.WebControls.ListControl.AddAttributesToRender(HtmlTextWriter writer) +41
System.Web.UI.WebControls.DropDownList.AddAttributesToRender(HtmlTextWriter writer) +47
System.Web.UI.WebControls.WebControl.RenderBeginTag(HtmlTextWriter writer) +20
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +20
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.HtmlControls.HtmlTableRow.RenderChildren(HtmlTextWriter writer) +46
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.HtmlControls.HtmlTable.RenderChildren(HtmlTextWriter writer) +46
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
FastReport.Web.WebReport.RenderContents(HtmlTextWriter writer) +86
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
and here is the report XML. It looks like its databound to me.
<?xml version="1.0" encoding="utf-8"?>
<Report ReportInfo.Created="06/01/2009 14:02:11" ReportInfo.Modified="06/01/2009 14:42:55" ReportInfo.CreatorVersion="1.1.7.0">
<Dictionary>
<ViewDataSource Name="SqlDataSource1" ReferenceName="SqlDataSource1" Enabled="true">
<Column Name="list_id" DataType="System.Int32"/>
<Column Name="name" DataType="System.String"/>
<Column Name="owner" DataType="System.String"/>
</ViewDataSource>
</Dictionary>
<ReportPage Name="Page1">
<ReportTitleBand Name="ReportTitle1" Width="718.2" Height="37.8"/>
<PageHeaderBand Name="PageHeader1" Top="41.8" Width="718.2" Height="28.35">
<TextObject Name="Text1" Left="56.7" Top="9.45" Width="94.5" Height="18.9" Text="[SqlDataSource1.list_id]"/>
<TextObject Name="Text2" Left="189" Top="9.45" Width="311.85" Height="18.9" Text="[SqlDataSource1.name]"/>
<TextObject Name="Text3" Left="529.2" Top="9.45" Width="94.5" Height="18.9" Text="[SqlDataSource1.owner]"/>
</PageHeaderBand>
<DataBand Name="Data1" Top="74.15" Width="718.2" Height="75.6"/>
<PageFooterBand Name="PageFooter1" Top="153.75" Width="718.2" Height="18.9"/>
</ReportPage>
</Report>
Thanks.
2) Your data band is not connected to data source:
<DataBand Name="Data1" Top="74.15" Width="718.2" Height="75.6"/>
there should be the DataSource="SqlDataSource1" attribute. To correct this, go the designer, double-click the databand and select datasource.
Original markup works well. The error happens if I delete runat="server" from the <form> node:
<form id="form1">
So, if you place WebReport in your form, be sure that it is configured to run at server.
Were you able to resolve this bug?
Thanks