.net ';您要求的报告需要更多信息';将SqlDataSource与Crystal报表一起使用时出错
我按照Microsoft教程在Visual Studio中创建了Crystal报表(使用v12.0),并使用.net ';您要求的报告需要更多信息';将SqlDataSource与Crystal报表一起使用时出错,.net,visual-studio,crystal-reports,webforms,.net,Visual Studio,Crystal Reports,Webforms,我按照Microsoft教程在Visual Studio中创建了Crystal报表(使用v12.0),并使用CrystalReportViewer、CrystalReportSource和SqlDataSource将其附加到web表单,因为我希望它从我的SQL Server实例读取数据。报告将加载一次带有以下web表单标记的精细(这似乎是嵌入.rpt文件中的快照数据): <CR:CrystalReportViewer ID="crystalReportViewer" runat="serv
CrystalReportViewer
、CrystalReportSource
和SqlDataSource
将其附加到web表单,因为我希望它从我的SQL Server实例读取数据。报告将加载一次带有以下web表单标记的精细(这似乎是嵌入.rpt文件中的快照数据):
<CR:CrystalReportViewer ID="crystalReportViewer" runat="server"
AutoDataBind="true"
GroupTreeImagesFolderUrl="" HasRefreshButton="True" Height="895px"
ReportSourceID="crystalReportSource" ToolbarImagesFolderUrl=""
ToolPanelWidth="200px" Width="1365px" />
<CR:CrystalReportSource ID="crystalReportSource" runat="server"
EnableCaching="False">
<Report FileName="ClientLoginHistory.rpt">
<DataSources>
<CR:DataSourceRef DataSourceID="sqlDataSource" />
</DataSources>
</Report>
</CR:CrystalReportSource>
<asp:SqlDataSource ID="sqlDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:dbReportsConnectionString %>"
SelectCommand="{{ select query is here }}">
</asp:SqlDataSource>
使用字段输入数据库登录信息
我之所以说“error”,是因为我故意按照教程将Crystal Report附加到SQL数据源,以便可以从我的Web.config中指定一个现有的连接字符串,其中预设了用户名和密码
实际上,它似乎甚至没有使用Web.config中的连接字符串,就好像我删除了对SqlDataSource的引用(请参见下面的代码段),它仍然使用快照数据加载,然后“刷新”提示用户/pass,并且一旦输入报告,就会很好地加载:
<CR:CrystalReportViewer ID="crystalReportViewer" runat="server"
AutoDataBind="true"
GroupTreeImagesFolderUrl="" HasRefreshButton="True" Height="895px"
ReportSourceID="crystalReportSource" ToolbarImagesFolderUrl=""
ToolPanelWidth="200px" Width="1365px" />
<CR:CrystalReportSource ID="crystalReportSource" runat="server"
EnableCaching="False">
</Report>
</CR:CrystalReportSource>
这样可以绕过连续提示。但是它非常讨厌,我不想用它
救命啊 在遵循了上面的代码和您提到的教程之后,我遇到了类似的问题。我发现,通过指定TableName属性,报表可以按预期运行,而无需设置任何登录参数
<CR:DataSourceRef DataSourceID="sqlDataSource" TableName="Chips" />
有趣,必须尝试。
protected void Page_Load(object sender, EventArgs e)
{
crystalReportSource.ReportDocument.SetDatabaseLogon("user", "real_pass");
}
<CR:DataSourceRef DataSourceID="sqlDataSource" TableName="Chips" />