CRYSTAL REPORT




















 CRYSTAL REPORT


 


  string
str = "select
p.productid,p.pname,op.orderid,o.customerid,o.unit,o.pdate,c.CUSTOMERID from
Products p inner join orderpurchase op on op.PRODUCTID=op.PRODUCTID inner
join ordersales o on o.PRODUCTID=op.PRODUCTID inner join CUSTOMERS c on c.CUSTOMERID=op.CUSTOMERID  where o.pdate='09/03/2012'"
;


 


         DataTable dt = new DataTable();


         command.Connection
= con;


         con.Open();


         command.CommandType
= CommandType.Text;


         command.CommandText
= str;


 


 


         da
= new SqlDataAdapter(command);


         da.Fill(dt);


         //*********************************************************


 


        ReportDocument rpt = new ReportDocument();


 


       rpt.Load(Server.MapPath("CrystalReport.rpt"));


       rpt.SetDataSource(dt);


 


       


        CrystalReportViewer1.ReportSource =
rpt;


        CrystalReportViewer1.DataBind();


 


 


   //METHOD1


      


 


         //*********************************************************


 


 


       


      //  da
= new SqlDataAdapter("select
p.productid,p.pname,op.orderid,o.customerid,o.unit,o.pdate,c.CUSTOMERID from
Products p inner join orderpurchase op on op.PRODUCTID=op.PRODUCTID inner
join ordersales o on o.PRODUCTID=op.PRODUCTID inner join CUSTOMERS c on c.CUSTOMERID=op.CUSTOMERID  where o.pdate='09/02/2012'", con);


 


 


       


         //METHOD3


        //USING sql VIEWS 
AND
DATASET


         //dsorder ds1 = new dsorder();


         //string str = "select p.productid,p.pname,op.orderid,o.customerid,o.unit,o.pdate,c.CUSTOMERID
from Products p inner join orderpurchase op on op.PRODUCTID=op.PRODUCTID inner
join ordersales o on o.PRODUCTID=op.PRODUCTID inner join CUSTOMERS c on c.CUSTOMERID=op.CUSTOMERID  where o.pdate='09/02/2012'";


 


         //da = new SqlDataAdapter(str, con);


         //da.Fill(ds1.Vieworders);


 


        //*********************************************************


         //METHOD4


        


         //string str = "SELECT CUSTOMERS.CUSTOMERID,Products.PRODUCTID,Products.pname,orderpurchase.ORDERID,ordersales.CUSTOMERID
AS Expr1,ordersales.UNIT,ordersales.pdate" +


 


         //" FROM  CUSTOMERS INNER
JOIN   orderpurchase
ON CUSTOMERS.CUSTOMERID = orderpurchase.CUSTOMERID"
+ " INNER JOIN  ordersales
ON CUSTOMERS.CUSTOMERID = ordersales.CUSTOMERID"
+ " INNER JOIN   Products ON orderpurchase.PRODUCTID = Products.PRODUCTID
AND ordersales.PRODUCTID = Products.PRODUCTID";


      


 







No comments:

Post a Comment

.Net References