| Mounilk 2006-01-19, 7:10 pm |
| Hi,
Although I am not programming C#, I am hoping that someone from
this group has had the problem and is able to help. Also, if you think
there is another more appropriate
group that i can post this to; please let me know.
From within Crystal Reports, my report displays the data; but when
i run my C# application, it displays a blank report (shows the text
objects) but does not display any data. I ran the query in the query
analyzer and it returns records. The report's datasource is a stored
procedure and it has 1 parameter.
Here's my code(C#):
private void btnShowReport_Click(object sender, System.EventArgs e)
{
CrystalDecisions.Windows.Forms.CrystalReportViewer crvReport;
ReportDocument rdEmployer;
Database crDatabase;
Tables crTables;
TableLogOnInfo crTableLogOnInfo;
ConnectionInfo crConnectionInfo;
rdEmployer = new ReportDocument();
rdEmployer.Load(strReportLocation);
crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "MyServer";
crConnectionInfo.DatabaseName = "MyDatabase";
crConnectionInfo.IntegratedSecurity = true;
crDatabase = rdEmployer.Database;
crTables = crDatabase.Tables;
foreach (Table crTable in crTables)
{
crTableLogOnInfo = crTable.LogOnInfo;
crTableLogOnInfo.ConnectionInfo = crConnectionInfo;
crTable.ApplyLogOnInfo(crTableLogOnInfo);
string sLocation = crConnectionInfo.DatabaseName +
".dbo." + crTable.Location.Substring(crTable.Location.LastIndexOf(".")
+ 1);
crTable.Location = sLocation;
crTable.LogOnInfo.ConnectionInfo.ServerName
=crConnectionInfo.ServerName;
}
CrvReport = new
CrystalDecisions.Windows.Forms.CrystalReportViewer();
crvReport.ReportSource = rdEmployer;
int iParameterCount = rdEmployer.ParameterFields.Count;
ParameterField[] arrParamFld= new
ParameterField[iParameterCount];
ParameterDiscreteValue[] arrParamDV= new
ParameterDiscreteValue[iParameterCount];
for (int i = 0; i < iParameterCount; i++)
{
arrParamFld[i] = crvReport.ParameterFieldInfo[i];
}
IDictionaryEnumerator dicParameterValues;
dicParameterValues =
lstParameterValues.GetEnumerator();
int iParameters;
iParameters = 0;
while (dicParameterValues.MoveNext())
{
object ParameterValue = dicParameterValues.Value;
arrParamDV[iParameters] = new
ParameterDiscreteValue();
arrParamDV[iParameters].Value = ParameterValue;
arrParamFld[iParameters].CurrentValues.Add(arrParamDV[iParameters]);
iParameters++;
}
this.WindowState =
System.Windows.Forms.FormWindowState.Maximized;
this.Controls.Add(crvReport);
crvReport.DisplayGroupTree= false;
crvReport.Dock = System.Windows.Forms.DockStyle.Fill;
crvReport.AutoScroll = true;
crvReport.ShowCloseButton = true;
crvReport.Visible = true;
crvReport.ShowRefreshButton = false;
}//btnShowReport_Click
Note:-
After the report loads up (WITHOUT the data), if i then press the
Refresh button on the
CrystalReportViewer, it pops up the Enter Parameter Values window
again, and then if i enter the parameter value, it displays the report
WITH the data. Any idea as to what's happening?
TIA,
Mounil.
|