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 rep
put your coding to load event while bind report don't put ispostback=false condition
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
Use EnableDatabaseLogonPrompt to see the actual error
Use Data Table instead of Data Set .. It works..
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.
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);
I had same problem but I found a simple solution. i.e. just replace dataset
with the data table
and it will work fine.
I have found the best way to fix a bug is to post the question to StackOverflow and 5 minutes later work it out yourself. Needless to say, I worked this out.
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.
<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;
}