Good morning folks
I have a simple crystal report with only one parameter field and this field is attatched to the report's record selection.
It works fine if I preview the report and type the value in the discreet value box.
My problem is that i have a form with a Crystal Report Viewer and i want MY application to provide the value for that parameter but i can't find anywhere over the web how to do it..
it seems simple but it's killing me...
someone please help?
Loading
Guilherme PaschoalPosted Jul 7, 2008, 8:28 AM
thanks for the help!
Ryan AlfordPosted Jul 5, 2008, 2:48 PM
ConnectionInfo crDbConnection = new ConnectionInfo();
crDbConnection.DatabaseName = Settings.ReadSettings("DatabaseName"); // reads from App.Config file
crDbConnection.ServerName = Settings.ReadSettings("ServerName");
crDbConnection.UserID = Settings.ReadSettings("UserName");
crDbConnection.Password = Settings.ReadSettings("Password");
ReportDocument oRpt = new ReportDocument();
oRpt = (ReportDocument)crystalReportViewer1.ReportSource;
Database crDatabase = oRpt.Database;
TableLogOnInfo oCrTableLoginInfo;
foreach (Table oCrTable in crDatabase.Tables)
{
oCrTableLoginInfo = oCrTable.LogOnInfo;
oCrTableLoginInfo.ConnectionInfo = crDbConnection;
oCrTable.ApplyLogOnInfo(oCrTableLoginInfo);
}
//The Parameters in the report
ParameterFields fields1 = new ParameterFields();
ParameterField field1 = new ParameterField();
ParameterDiscreteValue discrete1 = new ParameterDiscreteValue();
ParameterRangeValue range1 = new ParameterRangeValue();
field1.Name = "@Date";
discrete1.Value = Convert.ToDateTime(dtmToday.Value.ToString("MM/dd/yyyy"));
field1.CurrentValues.Add(discrete1);
fields1.Add(field1);
crystalReportViewer1.ParameterFieldInfo = fields1;
Guilherme PaschoalPosted Jul 4, 2008, 2:07 PM
U Don't need to answer my question anymore..
I'm just answering to this own thread of mine to help someone that might be just as a Crystal Reports as me and had the same doubt as me so, it's something really stupid that fits my needs like a glove, it's a simple line:
crptAloc1.RecordSelectionFormula = "{SGPTBLPROJ.PROJCODPROJETO}=" + codigoProjeto;
[report].RecordSelectionFormula = "{TABLEINREPORT.FIELDINREPORT}="+value;
stupid.
thanks anyway guys...