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

Issues with Function in Field with Reporting Parameters

3 Answers 353 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ricardo
Top achievements
Rank 1
Ricardo asked on 25 Aug 2012, 06:09 PM
Hi i'm trying to make a report with some functions on it, but i need the field value and two report parameters (date from, date to), but it always gives to me this error when i run it

An error has ocuured while processing TextBox 'asistenciasDataTextBox':
The expression contains undefined function call Asistencias().


I double checked and i have that function in my class, here it is

public static string Asistencias(string cedula, DateTime desde, DateTime hasta)
        {
            string WDcon = ConfigurationManager.ConnectionStrings["WindowsFormsApplication2.Properties.Settings.DBGriauleConnectionString"].ConnectionString;
            //Llamo la conexion SQL
            SqlConnection Wdcon_usuario = new SqlConnection(WDcon);
            SqlCommand usuario = new SqlCommand();
            SqlDataReader usuarioDR = null;
            //Instancio la conexion SQL
            usuario.Connection = Wdcon_usuario;
 
            //Registro el Query SQL
            usuario.CommandText = "SELECT COUNT(*) AS Expr1 FROM asistencias WHERE (ID = @cedula) AND (asistio = 1) AND (fecha >= @desde) AND (fecha <= @hasta)";
            usuario.Parameters.AddWithValue("@cedula", cedula);
            usuario.Parameters.AddWithValue("@desde", desde);
            usuario.Parameters.AddWithValue("@hasta", hasta);
 
            //Abro la conexion
            Wdcon_usuario.Open();
 
            //Ejecuto la consulta
            usuarioDR = usuario.ExecuteReader();
            int respuesta = 0;
 
            while (usuarioDR.Read())
            {
                respuesta = (int)usuarioDR["Expr1"];
            }
 
            Wdcon_usuario.Close();
            return respuesta.ToString();
        }
 
And changed the Field Value, when i run it, it doesn't work, is something wrong???

= WindowsFormsApplication2.Funciones.Asistencias(Fields.Asistencias, Parameters.DESDE.Value, Parameters.HASTA.Value)

3 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 28 Aug 2012, 03:22 PM
Hello,

There are three reasons for such kind of error, listed in the The expression contains undefined function call MyUserFunction() error KB article. Review it carefully and let us know if further help is needed.

Kind regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Ricardo
Top achievements
Rank 1
answered on 28 Aug 2012, 04:01 PM
Hello thanks for replying my post, i already tested the 3 points from that article

  1. The class library has not been rebuilt and thus the function does not yet exist.
  2. Using the function with wrong number/type of parameters. The passed fields must match the function signature you've defined originally.
  3. A field specified as function argument is null. Make sure that such cases are handled in the user function.



1.) The class library was rebuilt serveral times
2.) I use the right  functions parameters (you can see them on my fist thread from this post)
3.) Is not tnull the fields, i already tested it on sql server
0
Steve
Telerik team
answered on 03 Sep 2012, 10:47 AM
Hello Ricardo,

Judging by the expression for the function, the user function (and supposedly reports as well) are contained directly in your Windows Forms application. If you have created this expression by double clicking on the user function in the Expression editor, this means the project is built as it sees the function. We however cannot confirm anything for #2 and #3 as we do not have your data. Set your user function arguments to object instead of their supposed type and debug your user function to make sure they are really of this type.

On a side note, changing your datasource in a user function depending on parameters' values is not the recommended way to do things. Instead we suggest using SqlDataSource Component to bind to your database and wire up your SqlDataSourceParameter to the ReportParameter directly in the designer. See the following help articles for more information:

Greetings,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Ricardo
Top achievements
Rank 1
Answers by
Steve
Telerik team
Ricardo
Top achievements
Rank 1
Share this question
or