locked
Crytal Report from Multiple Table RRS feed

  • Question

  • User218949881 posted

    I want to display crystal report from multiple table's but it didn't show please check code, 

    string info = ConfigurationManager.ConnectionStrings["KiranTradersContext"].ConnectionString;

    SqlConnection mycon = new SqlConnection(info);
    mycon.Open();
    string sql = "Select SaleID , c.Name , p.ProductType , s.Date ,s.City, s.Mobile, s.TruckNo,s.Packets,s.Weight,s.Rate,s.Total from sale s, Product p , Customer c where s.ProductID=p.ProductID and s.CustomerID=c.CustomerID";
    SqlDataAdapter myda = new SqlDataAdapter(sql, mycon);


    Reporting ds = new Reporting();

    myda.TableMappings.Add("Sale", "Sale");  i used this for try but it also didn't work
    myda.TableMappings.Add("Customer", "Customer");
    myda.TableMappings.Add("Product", "Product");
    //myda.Fill(ds, "Sale,Customer,Product");if i pass here only one table it is showing result. 

    ReportDocument myrpt = new ReportDocument();
    myrpt.Load(Server.MapPath("~/Reports/Saleone.rpt"));
    myrpt.SetDataSource(ds);
    CrystalReportViewer1.ReportSource = myrpt;

    Wednesday, May 27, 2015 9:14 AM

All replies

  • User61956409 posted

    Hi ameetkumar,

    Thanks for your post.

    Firstly, you could try the following code.

    string info = ConfigurationManager.ConnectionStrings["KiranTradersContext"].ConnectionString;
    
    SqlConnection mycon = new SqlConnection(info);
    mycon.Open();
    string sql = "Select SaleID , c.Name , p.ProductType , s.Date ,s.City, s.Mobile, s.TruckNo,s.Packets,s.Weight,s.Rate,s.Total from sale s, Product p , Customer c where s.ProductID=p.ProductID and s.CustomerID=c.CustomerID";
    SqlDataAdapter myda = new SqlDataAdapter(sql, mycon);
    
    DataSet ds = new DataSet();
    myda.Fill(ds);
    
    ReportDocument myrpt = new ReportDocument();
    myrpt.Load(Server.MapPath("~/Reports/Saleone.rpt"));
    myrpt.SetDataSource(ds);
    CrystalReportViewer1.ReportSource = myrpt; 
    

    Secondly, you could post the problem in Crystal Reports forum for help.

    Best Regards,

    Fei Han

    Friday, May 29, 2015 5:04 AM
  • User218949881 posted

    Hello 

    It didn't work 

    Friday, May 29, 2015 7:46 AM