I have some Crystal Reports that were created using Crystal (external to Visual Studio) and are now loaded in the VS project. Before the report is previewed I set up the report database information like this in the report and all subreports.
我有一些使用Crystal(Visual Studio外部)创建的Crystal Reports,现在已加载到VS项目中。在预览报表之前,我在报表和所有子报表中设置了这样的报表数据库信息。
var connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "192.168.x.xxx";
connectionInfo.DatabaseName = "xxxx";
connectionInfo.Password = "xxxx";
connectionInfo.UserID = "xxxx";
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.IntegratedSecurity = false;
TableLogOnInfo logon = table.LogOnInfo;
table.LogOnInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(logon);
The report displays correctly when it is initially previewed but when I go to the next page in the report preview I get the message, "The report you requested requires further information" and are prompted for the database login information again. Once I have entered it here I am no longer prompted. It appears that the initial ConnectionInfo I set up is not sticking past the first page.
报告最初预览时报告正确显示,但当我转到报告预览中的下一页时,我收到消息“您请求的报告需要更多信息”,并再次提示您输入数据库登录信息。一旦我在这里输入,我就不再被提示了。我设置的初始ConnectionInfo似乎没有超过第一页。
I am using Crystal XI and Visual Studio 2008.
我正在使用Crystal XI和Visual Studio 2008。
8 个解决方案
#1
I have found the best way to fix a bug is to post the question to * and 5 minutes later work it out yourself. Needless to say, I worked this out.
我发现修复bug的最好方法是将问题发布到*,5分钟后自己解决。不用说,我解决了这个问题。
As well as setting all the log on info in the report objects, I also have to do it in the Crystal Viewer component in ASP.NET. So I just write some code like this and it all works, no prompts.
除了在报表对象中设置所有登录信息之外,我还必须在ASP.NET中的Crystal Viewer组件中执行此操作。所以我只是写了一些像这样的代码,一切正常,没有提示。
<CR:CrystalReportViewer Height="500px" ID="Viewer" runat="server" />
var connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "192.168.x.xxx";
connectionInfo.DatabaseName = "xxxx";
connectionInfo.Password = "xxxx";
connectionInfo.UserID = "xxxx";
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.IntegratedSecurity = false;
for (int i = 0; i < Viewer.LogOnInfo.Count; i++)
{
Viewer.LogOnInfo[i].ConnectionInfo = connectionInfo;
}
#2
Try to set the EnableDatabaseLogonPrompt
property in the crystal report viewer to false;
尝试将crystal report viewer中的EnableDatabaseLogonPrompt属性设置为false;
#3
Use Data Table instead of Data Set .. It works..
使用数据表而不是数据集..它的工作原理..
#4
put your coding to load event while bind report don't put ispostback=false condition
把你的编码加载到事件绑定报告时不要把ispostback = false条件
example
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As New dsPrintRevisionStatus
Try
lblHeader.Text = Request.QueryString("name")
If lblHeader.Text = "Report- Print Revision Status" Then
Dim rpt As New rpt_PrintRevisionStatus
rpt.SetDataSource(sqlHandler.ExecuteDataTable("SELECT * FROM [Print Revision Status]"))
crtViewer.ReportSource = rpt
crtViewer.DataBind()
End If
Catch ex As Exception
lblError.Text = ex.Message
End Try
End Sub
#5
I had same problem but I found a simple solution. i.e. just replace dataset
with the data table
and it will work fine.
我有同样的问题但我找到了一个简单的解决方案。即只是用数据表替换数据集,它将正常工作。
#6
If you have added the logon info as follows,
如果您已添加登录信息,如下所示,
LogInfo.ConnectionInfo.ServerName = "mcqueen";
LogInfo.ConnectionInfo.Password = "abc123";
LogInfo.ConnectionInfo.UserID = "sa";
LogInfo.ConnectionInfo.DatabaseName = "tbboss";
crysViewer.LogOnInfo.Add(LogInfo);
simply put the crysViewer.LogOnInfo.Add(LogInfo); at the end of crystal Viewer parameter settings. Like follows.
简单地把crysViewer.LogOnInfo.Add(LogInfo);在crystal Viewer参数设置结束时。如下。
LogInfo.ConnectionInfo.ServerName = "mcqueen";
LogInfo.ConnectionInfo.Password = "abc123";
LogInfo.ConnectionInfo.UserID = "sa";
LogInfo.ConnectionInfo.DatabaseName = "tbboss";
int exportFormatFlags =(int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat | CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat);
crysViewer.AllowedExportFormats = exportFormatFlags;
crysViewer.ReportSource = Server.MapPath("Reports/Report1.rpt");
crysViewer.ParameterFieldInfo = paramFields;
crysViewer.LogOnInfo.Add(LogInfo);
#7
Use EnableDatabaseLogonPrompt to see the actual error
使用EnableDatabaseLogonPrompt查看实际错误
#8
#1
I have found the best way to fix a bug is to post the question to * and 5 minutes later work it out yourself. Needless to say, I worked this out.
我发现修复bug的最好方法是将问题发布到*,5分钟后自己解决。不用说,我解决了这个问题。
As well as setting all the log on info in the report objects, I also have to do it in the Crystal Viewer component in ASP.NET. So I just write some code like this and it all works, no prompts.
除了在报表对象中设置所有登录信息之外,我还必须在ASP.NET中的Crystal Viewer组件中执行此操作。所以我只是写了一些像这样的代码,一切正常,没有提示。
<CR:CrystalReportViewer Height="500px" ID="Viewer" runat="server" />
var connectionInfo = new ConnectionInfo();
connectionInfo.ServerName = "192.168.x.xxx";
connectionInfo.DatabaseName = "xxxx";
connectionInfo.Password = "xxxx";
connectionInfo.UserID = "xxxx";
connectionInfo.Type = ConnectionInfoType.SQL;
connectionInfo.IntegratedSecurity = false;
for (int i = 0; i < Viewer.LogOnInfo.Count; i++)
{
Viewer.LogOnInfo[i].ConnectionInfo = connectionInfo;
}
#2
Try to set the EnableDatabaseLogonPrompt
property in the crystal report viewer to false;
尝试将crystal report viewer中的EnableDatabaseLogonPrompt属性设置为false;
#3
Use Data Table instead of Data Set .. It works..
使用数据表而不是数据集..它的工作原理..
#4
put your coding to load event while bind report don't put ispostback=false condition
把你的编码加载到事件绑定报告时不要把ispostback = false条件
example
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dt As New dsPrintRevisionStatus
Try
lblHeader.Text = Request.QueryString("name")
If lblHeader.Text = "Report- Print Revision Status" Then
Dim rpt As New rpt_PrintRevisionStatus
rpt.SetDataSource(sqlHandler.ExecuteDataTable("SELECT * FROM [Print Revision Status]"))
crtViewer.ReportSource = rpt
crtViewer.DataBind()
End If
Catch ex As Exception
lblError.Text = ex.Message
End Try
End Sub
#5
I had same problem but I found a simple solution. i.e. just replace dataset
with the data table
and it will work fine.
我有同样的问题但我找到了一个简单的解决方案。即只是用数据表替换数据集,它将正常工作。
#6
If you have added the logon info as follows,
如果您已添加登录信息,如下所示,
LogInfo.ConnectionInfo.ServerName = "mcqueen";
LogInfo.ConnectionInfo.Password = "abc123";
LogInfo.ConnectionInfo.UserID = "sa";
LogInfo.ConnectionInfo.DatabaseName = "tbboss";
crysViewer.LogOnInfo.Add(LogInfo);
simply put the crysViewer.LogOnInfo.Add(LogInfo); at the end of crystal Viewer parameter settings. Like follows.
简单地把crysViewer.LogOnInfo.Add(LogInfo);在crystal Viewer参数设置结束时。如下。
LogInfo.ConnectionInfo.ServerName = "mcqueen";
LogInfo.ConnectionInfo.Password = "abc123";
LogInfo.ConnectionInfo.UserID = "sa";
LogInfo.ConnectionInfo.DatabaseName = "tbboss";
int exportFormatFlags =(int)(CrystalDecisions.Shared.ViewerExportFormats.PdfFormat | CrystalDecisions.Shared.ViewerExportFormats.ExcelFormat);
crysViewer.AllowedExportFormats = exportFormatFlags;
crysViewer.ReportSource = Server.MapPath("Reports/Report1.rpt");
crysViewer.ParameterFieldInfo = paramFields;
crysViewer.LogOnInfo.Add(LogInfo);
#7
Use EnableDatabaseLogonPrompt to see the actual error
使用EnableDatabaseLogonPrompt查看实际错误