Thank you the reply. I changed the method because I felt that I could not get control over the where clause. Some years ago I created Crystal reports and my method was to define the structure of data source with an xsd and give the data through a DataSet collected by me. Now I wanted to repeat this method but though every name was correct the report still was empty. Here is the code:
public class DeliveryFactory
{
private ToolPoolingDataContext DC;
private String reportPath = @"c:\Develop\Viewstore\ToolPooling\bugstools_GB_Utilities\ToolPooling\ToolPoolingService\Reports\";
public DeliveryFactory(ToolPoolingDataContext dc)
{
DC = dc;
}
public void CreateReport(int rental_ID)
{
List<V_DELIVERY> del = (from d in DC.V_DELIVERies where d.Rental_ID == rental_ID select d).ToList();
if (del.Count == 0)
return;
List<V_TOOL> tool = (from d in DC.V_TOOLs where d.Rental_ID == rental_ID select d).ToList();
if (tool.Count == 0)
return;
Delivery rep = new Delivery();
try
{
DataSet dsDelivery = new DataSet("DeliverySchema");
DataTable dtDel = new DataTable("V_DELIVERY");
dtDel.Columns.Add("AllocatedByName", typeof(String));
dtDel.Columns.Add("City", typeof(String));
dtDel.Columns.Add("CompanyName", typeof(String));
dtDel.Columns.Add("ContactName", typeof(String));
dtDel.Columns.Add("ContactOrgUnit", typeof(String));
dtDel.Columns.Add("ContactPhone", typeof(String));
dtDel.Columns.Add("CountryName", typeof(String));
dtDel.Columns.Add("Currency", typeof(String));
dtDel.Columns.Add("Location", typeof(String));
dtDel.Columns.Add("PostalCode", typeof(String));
dtDel.Columns.Add("Rental_ID", typeof(int));
dtDel.Columns.Add("ToolCount", typeof(int));
dtDel.Columns.Add("UsingStart", typeof(DateTime));
dsDelivery.Tables.Add(dtDel);
DataRow dtRow = dtDel.Rows.Add();
dtRow["AllocatedByName"] = del[0].AllocatedByName;
dtRow["City"] = del[0].City;
dtRow["CompanyName"] = del[0].CompanyName;
dtRow["ContactName"] = del[0].ContactName;
dtRow["ContactOrgUnit"] = del[0].ContactOrgUnit;
dtRow["ContactPhone"] = del[0].ContactPhone;
dtRow["CountryName"] = del[0].CountryName;
dtRow["Currency"] = del[0].Currency;
dtRow["Location"] = del[0].Location;
dtRow["PostalCode"] = del[0].PostalCode;
dtRow["Rental_ID"] = del[0].Rental_ID;
dtRow["ToolCount"] = del[0].ToolCount;
dtRow["UsingStart"] = del[0].UsingStart;
DataTable dtTool = new DataTable("V_TOOL");
dtTool.Columns.Add("AccessoryName", typeof(String));
dtTool.Columns.Add("no", typeof(int));
dtTool.Columns.Add("Rental_ID", typeof(int));
dtTool.Columns.Add("SN", typeof(String));
dtTool.Columns.Add("ToolName", typeof(String));
dtTool.Columns.Add("Tool_ID", typeof(int));
dsDelivery.Tables.Add(dtTool);
foreach (V_TOOL t in tool)
{
dtRow = dtTool.Rows.Add();
dtRow["AccessoryName"] = t.AccessoryName;
dtRow["no"] = t.no;
dtRow["Rental_ID"] = t.Rental_ID;
dtRow["SN"] = t.SN;
dtRow["ToolName"] = t.ToolName;
dtRow["Tool_ID"] = t.Tool_ID;
}
rep.SetDataSource(dsDelivery);
//rep.ReadRecords();
rep.ExportToDisk(ExportFormatType.PortableDocFormat, reportPath + "Delivery.pdf");
}
catch (Exception e)
{
}
}
}
The report was created with the proper DataTable names and proper Field names but no data was inserted into the report when I used the SetDataSource method. Both of two tables contained data. Could you tell me what is wrong?