RDLC报告未加载数据

时间:2014-04-18 11:33:42

标签: c# asp.net c#-4.0 reportviewer rdlc

我开发了一个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);
    }

网络服务:

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 个答案:

答案 0 :(得分:0)

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