Hi
I created a crystal report but it doesn't show data.
It works with a free online database. The web page in my example is: WebForm2.aspx
I am not sure about the exact error.
This the link of the project: https://drive.google.com/open?id=0B7y0uYSDVYmJV3Y3OC1qcm1oRFE
My c# code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;
using System.Diagnostics;
using CrystalDecisions.CrystalReports.Engine;
namespace WebApplication1
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
}
}
private void Crystal()
{
var tiempo = new Stopwatch();
tiempo.Start();
var db = ClassDB.Reporting();
var reporte = new ReportDocument();
reporte.Load(Server.MapPath("~/CrystalReport1.rpt"));
reporte.SetDataSource(db);
this.CrystalReportViewer1.ReportSource = reporte;
CrystalReportViewer1.DataBind();
tiempo.Stop();
Response.Write("crystal: " + tiempo.ElapsedMilliseconds);
}
protected void Button1_Click(object sender, EventArgs e)
{
Crystal();
}
}
}
The first page is: WebForm2.aspx and you only have to perform click in "button"..
The unique error that I receive is : Function evaluation was disabled because a previous function evaluation exceeded the specified time
in the line: reporte.SetDataSource(db);
This is the method which load the data...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
namespace WebApplication1
{
public static class ClassDB
{
public static List<test> Reporting()
{
var results = new List<test>();
using (SqlConnection _con = new SqlConnection("server=TestReporting.mssql.somee.com;database=TestReporting;user id=aguil172;pwd=Server01"))
{
string queryStatement = "select * from test";
using(SqlCommand _cmd = new SqlCommand(queryStatement, _con))
{
_con.Open();
using (SqlDataReader reader = _cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
int codigo = reader.GetOrdinal("codigo");
while (reader.Read())
{
var test = new test
{
codigo = (int)reader[codigo]
};
results.Add(test);
}
}
}
return results.Where(x=> x.codigo == 0).ToList();
}
}
}
public class test
{
public int codigo { get; set; }
}
}
This is the crystal report:
![tfsdd]()