views:

31

answers:

2

this is a formula that i have used to select records based on string array 'aa '

crystalReportViewer1.SelectionFormula = "({Table3.logindate} = '" + aa[i] + "')" for e.g aa[i]=aa[0],aa[1],aa[2] it will select only the records of aa[2] please give me a valuable solution

A: 

Try this

string formula = string.Empty;
formula = "(";
for(int i = 0; i< aa.Length - 1; i++)
{
formula += "{Table3.logindate} = '" + aa[i] + "'" 
if(i != aa.length -1)
{
formula += " && " //I don't know && works for AND operator in SelectionFormula 
}
}
formula = ")";
crystalReportViewer1.SelectionFormula = formula ;

And it is no to neglect error, it is to fix the error. ;)

Anuraj
Won't this just overwrite the formula each time?
Ruben Bartelink
now i got reports only for aa[0]
ush
plz suggest me any another way
ush
I edited the code.
Anuraj
@Ruben Bartelink - Yes I think, it is my mistake. Anyway I modified the code.
Anuraj
very thanks for u. it is not working plz suggest any other way
ush
thank you so much
ush
A: 

You'd be much better off to create a crystal parameter that allows multiple values (essentially an array). Then you simply set the parameter value in code...

rptDoc.SetParameterValue("param_name", aa);

then your crystal selection formula becomes...

{Table3.logindate} in {param_name}
dotjoe