RDLC报告未加载数据

时间:2021-10-18 23:55:47

I have developed an asp.net app which should display RDLC report which i am loading from database by calling web service. That web service is good and ok but RDLC is not being loaded with data. It shows blank RDLC instead of showing database data (Longitude, latitude)

我开发了一个asp.net应用程序,它应该显示我正在通过调用Web服务从数据库加载的RDLC报告。该Web服务很好,但是RDLC没有加载数据。它显示空白RDLC而不是显示数据库数据(经度,纬度)

CODE:

码:

protected void Page_Load(object sender, EventArgs e)
{
    GPSWebservice gs = new GPSWebservice();
    List<Coordinates> lstcoords = new List<Coordinates>(gs.FetchCoordinates("hunain-8888881 ,2014-04-17 18:22, 2014-04-17 20:20:00.000"));

    if (!IsPostBack)
    {
        ReportViewer1.ProcessingMode = ProcessingMode.Local;
        ReportViewer1.LocalReport.ReportPath = Server.MapPath("~/Report.rdlc");
        // Customers dsCustomers = GetData("select top 20 * from customers");
        ReportDataSource datasource = new ReportDataSource("Coordinates", lstcoords);
        ReportViewer1.LocalReport.DataSources.Clear();
        ReportViewer1.LocalReport.DataSources.Add(datasource);
    }

Web service :

网络服务 :

public List<Coordinates> FetchCoordinates(String FetchParam) 
{
    List<Coordinates> Coords = new List<Coordinates>();
    Coordinates c;

    if(String.IsNullOrEmpty(FetchParam))
    {
        c = new Coordinates()
        {
             Error = "No Input Provided"
        };
        Coords.Add(c);
        return Coords;
    }

    String[] parts = FetchParam.Split(',');
    sqlCom.CommandText = "FetchCoordinates";
    sqlCom.CommandType = CommandType.StoredProcedure;

    String IMEI = parts[0].ToString();
    DateTime DateTimeFrom = Convert.ToDateTime(parts[1]); 
    DateTime DateTimeTo = Convert.ToDateTime(parts[2]);

    sqlCom.Parameters.Add("@IMEI", SqlDbType.VarChar).Value = IMEI;
    sqlCom.Parameters.Add("@DateTimeFrom", SqlDbType.DateTime).Value = DateTimeFrom.AddSeconds(-DateTimeFrom.Second);
    sqlCom.Parameters.Add("@DateTimeTo", SqlDbType.DateTime).Value = DateTimeTo.AddSeconds(-DateTimeTo.Second);
    SqlParameter sqlParam = new SqlParameter("@result", SqlDbType.Int);
    sqlCom.Parameters.Add(sqlParam);
    sqlCom.Parameters["@result"].Direction = ParameterDirection.Output;

    try
    {
        sqlCon.Open();
        using (SqlDataReader reader = sqlCom.ExecuteReader())
        {
             if (reader.HasRows)
             {
                  while (reader.Read())
                  {
                      c = new Coordinates()
                      {
                           Longitude = reader["Longitude"].ToString(),
                           Latitude = reader["Latitude"].ToString(),
                           // Error = "Times:"+"Original="+DateTimeFrom+"<br/>"+"Trimmed Time"+DateTimeFrom.AddSeconds(-DateTimeFrom.Second)
                      };
                            Coords.Add(c);

                  }
                  return Coords;
             }
             else
             {
                  c = new Coordinates()
                  {
                       Error = "No Data Found for Given Input. Could be Server Error or Try Changing IMEI or DateTime Format"
                  };
                  Coords.Add(c);
                  return Coords;
             }
        }
    }

    catch (Exception)
    {

        c = new Coordinates() 
        { 
             Error = "Something Went Wrong" 
        };
        Coords.Add(c);
        return Coords;

    }

    finally
    {
        sqlCon.Close();
    }
}

1 个解决方案

#1


0  

I had the same problem, I had some line (object) in my report, deleted and it showing

我有同样的问题,我在报告中有一些行(对象),删除并显示

#1


0  

I had the same problem, I had some line (object) in my report, deleted and it showing

我有同样的问题,我在报告中有一些行(对象),删除并显示