I've created a simplest of the web site in VS 2008. Default.aspx has a hyperlink to report name.
When user clicks on hyperlink report should be previewed.
Every time I launch the website, Report shows data it was saved with and do not refresh the data automatically.
Also it does not prompt for the parameters.
If I click the refresh button it asks me for for database credentials - I don't want user to input database credentials every time.
Can you suggest solution to achieve above 3 points.
Code on click of hyperlink is.
<div>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Default.aspx"
Target="_self">Backasp:HyperLink>
<CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"
ReportSourceID="CrystalReportSource2" Height="1055px"
Width="820px" EnableDatabaseLogonPrompt="False" HasRefreshButton="True"
ReuseParameterValuesOnRefresh="True" />
<CR:CrystalReportSource ID="CrystalReportSource2" runat="server">
<Report FileName="C:\ranjit on Aad95683\GTMS\GTMSWeb\GTMS_POB.rpt">
Report>
CR:CrystalReportSource>
div>
Ranjit ChikhalkarPosted Oct 15, 2008, 2:55 PM
Solved.
Changed
connectionInfo.DatabaseName = "GTMS_Prod" with
connectionInfo.ServerName = "GTMS_Prod"
Ranjit ChikhalkarPosted Oct 15, 2008, 2:19 PM
I've resolved this problem by feeding log-in information to the database as in below code.
Now it connects to the database but My report uses Command inside it. And I get error Command.Name - field not found. This is because it does not recorgnise command as one of the tables.
How do I tackle this?
private
void ConfigureCrystalReports(){
rpt =
new ReportDocument(); string reportPath = Server.MapPath("GTMS_POB.rpt");rpt.Load(
"C:\\ranjit on Aad95683\\GTMS\\GTMSWeb\\GTMS_POB.rpt"); ConnectionInfo connectionInfo = new ConnectionInfo();connectionInfo.DatabaseName =
"GTMS_Prod";connectionInfo.UserID =
"GTMSREPORT";connectionInfo.Password =
"S3IDReport";SetDBLogonForReport(connectionInfo, rpt);
CrystalReportViewer1.ReportSource = rpt;
/*CrystalReportViewer1.EnableDatabaseLogonPrompt = false;CrystalReportViewer1.LogOnInfo;*/
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument){
Tables tables = reportDocument.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables){
TableLogOnInfo tableLogonInfo = table.LogOnInfo;tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
}