InvalidCAstException

Posted by Tanwar18 under C# on 5/4/2012 | Points: 10 | Views : 1601 | Status : [Member] | Replies : 0
public DateTime PostDate
{

get { return this.Parameters.GetFieldValue<DateTime>("PostDate"); }
set { this.Parameters.SetFieldValue("PostDate", value); }
}

public DateTime ToDate
{

get { return this.Parameters.GetFieldValue<DateTime>("ToDate"); }
set { this.Parameters.SetFieldValue("ToDate", value); }
}


protected override bool CreateCrystalStrings()
{

bool result = true;

StringBuilder whereString = new StringBuilder();
StringBuilder SQLWhereString = new StringBuilder();
StringBuilder descString = new StringBuilder();


if (this.PostDate >new DateTime(1900, 4, 4) || this.ToDate >new DateTime(1900, 12, 4))
{
whereString.Append("{R_chgdetrollup.added} in " + ReportHelper.CrystalDate(this.PostDate) +
" to " + ReportHelper.CrystalDate(this.ToDate, true) + " and ");
SQLWhereString.Append("(R_chgdetrollup.added between " + ReportHelper.ToSQLDate(this.PostDate) +
" and " + ReportHelper.ToSQLDate(this.ToDate, true) + ") and ");

}

this.crystalWhereClause = whereString.ToString();
this.englishDescription = descString.ToString();
this.sqlWhereClause = SQLWhereString.ToString();

this.crystalWhereClause = this.crystalWhereClause.Substring(0, this.crystalWhereClause.Length - 4);
this.sqlWhereClause = this.sqlWhereClause.Substring(0, this.sqlWhereClause.Length - 4);
if (this.testingForm)
{
this.txtDescription.Text = this.englishDescription;
this.txtSQLWhereString.Text = this.sqlWhereClause;
this.txtWhereString.Text = this.crystalWhereClause;
}
return result;

}


Now when i run it.. an exception of InvalidCastException is came....
Specified cast is not valid... Value is not coming in the GetFieldValue of Property, both in PostDate and ToDate..
What change should i made and where..?

Plz help me out....




Responses

(No response found.)

Login to post response