This is a migrated thread and some comments may be shown as answers.

RE:User Defined function - undefined function call

1 Answer 158 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abiri Masoni
Top achievements
Rank 1
Abiri Masoni asked on 23 Apr 2010, 11:52 AM

Hi all!

I have a Master report containing a sub report. In the sub report i'm trying to use a userdefined function called returnThis(). Below are the two versions of the function.

 

public static double returnThis()

        {

            return 22.6;

        }

 

        //public static double returnThis(double avgMark)

        //{

        //    //SqlConnection conn = null;

 

        //    //conn = new SqlConnection("Data Source=AGAHIMBARE-PC;Initial Catalog=VTLARIMS;Integrated Security=True");

 

        //    //conn.Open();

        //    //string strSQLCommand = "SELECT Top(1) GradePoint FROM  GradeMarks WHERE avgMark BETWEEN LowerPercentage AND UpperPercentage";

        //    //SqlCommand command = new SqlCommand(strSQLCommand, conn);

        //    //string xx = command.ExecuteScalar().ToString();

        //    //   double returnvalue = System.Convert.ToDouble(xx);

        //    //conn.Close();

        //   // return returnvalue;

        //    return avgMark;

        //}

 

when i use the one without any argument, it works fine ie. returns 22.6
However when i use the one which is passed a parameter (the disabled one) i get "An error occured while trying to process text box. The expression contains undefined function call returnThis()"

 

 

I call the function using  =returnThis(52.1) as the value for a textbox on the subreport.

 

Can anyone help me here plz. Thnx so much.

1 Answer, 1 is accepted

Sort by
0
Mike
Top achievements
Rank 1
answered on 15 Aug 2011, 09:51 PM
Hello,

This is really late of course, but I had the exact same issue just now...

I got it to work by doing a conversion of the parameter in the expression.

So if I have MyParameter as an integer and:
MyClass.MyFunction(X as integer)

and do =MyClass.MyFunction(Parameters.MyParameter.Value)

This fails, but =MyClass.MyFunction(CInt(Parameters.MyParameter.Value)) works...

Maybe this will help somebody else someday.

Hope all's well,

Mike
Tags
General Discussions
Asked by
Abiri Masoni
Top achievements
Rank 1
Answers by
Mike
Top achievements
Rank 1
Share this question
or