[英]RDLC report not loading with data
我已经开发了一个asp.net应用程序,该应用程序应显示RDLC报告,该报告是通过调用Web服务从数据库加载的。 该Web服务很好并且可以,但是RDLC并未加载数据。 它显示空白的RDLC而不是显示数据库数据(经度,纬度)
码:
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();
}
}
我遇到了同样的问题,我的报告中有一些行(对象),已删除并显示
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.