.NET Logo
Welcome Guest Search | Active Topics | Members | Log In | Register

ขอถาม Crystal Report 2 ตาราง จะนำมาใส่อย่างไหรคับ ตอบทีคับด่วน Options · View
zerozaaa
Posted: Wednesday, October 01, 2008 9:49:16 PM
Rank: มือพระกาฬ
Groups: Member

Joined: 6/13/2008
Posts: 79

 

 string strConn;
            string billorder;
            strConn = WebConfigurationManager.ConnectionStrings["My_data"].ConnectionString;
            SqlConnection Conn = new SqlConnection(strConn);
            Conn.Open();
 
            string showname;
            showname = "SELECT order_sale.id_cus,order_sale.date,register_customer.name_cus,register_customer.address_cus,register_customer.tel_cus,bill.address_sent,bill.name_sent,order_sale.id_bill FROM bill,register_customer,order_sale WHERE register_customer.id_cus = order_sale.id_cus AND order_sale.id_bill = '" + Session["id_bill"] + "' AND bill.id_bill = order_sale.id_bill ";
          
            SqlDataAdapter da1 = new SqlDataAdapter(showname, Conn);
 
            DataSet ds1 = new DataSet();
            da1.Fill(ds1, "bill");
 
            //ReportDocument rd = new ReportDocument();
            //rd.Load(Server.MapPath("CRbill_order.rpt"));
            //rd.SetDataSource(ds1.Tables["bill"]);
            //CrystalReportViewer1.ReportSource = rd;
 
            Lid_cus.Text = ds1.Tables[0].Rows[0][0].ToString();
            Ldate.Text = ds1.Tables[0].Rows[0][1].ToString();
            Lname.Text = ds1.Tables[0].Rows[0][2].ToString();
            Laddress.Text = ds1.Tables[0].Rows[0][3].ToString();
            Ltel.Text = ds1.Tables[0].Rows[0][4].ToString();
            Label1.Text = ds1.Tables[0].Rows[0][5].ToString();
            Label2.Text = ds1.Tables[0].Rows[0][6].ToString();
            Lidbill.Text = ds1.Tables[0].Rows[0][7].ToString();
 
            billorder = "SELECT order_sale.id_product,product.name_product,order_sale.saleproduct,order_sale.amount,order_sale.mix FROM order_sale,product WHERE id_bill = '" + Session["id_bill"] + "' AND order_sale.id_product = product.id_product ";
 
 
            SqlDataAdapter da = new SqlDataAdapter(billorder, Conn);
 
            DataSet ds = new DataSet();
            da.Fill(ds, "product");
 
            Gv_bill.DataSource = ds.Tables["product"];
            Gv_bill.DataBind();
 
            //ReportDocument rd1 = new ReportDocument();
            //rd1.Load(Server.MapPath("CRbill_order.rpt"));
            //rd1.SetDataSource(ds.Tables["product"]);
            //CrystalReportViewer1.ReportSource = rd1;
 ส่วนของ data set ดังนี้คับ แล้วจะ เขียน โค๊ดยังไงคับ

birdalter
Posted: Thursday, October 02, 2008 7:19:50 PM

Rank: มือเทพ
Groups: Member

Joined: 12/17/2007
Posts: 67

สร้าง view ใน SqlServer ไว้ก่อนครับแล้วค่อยสร้าง Dataset จาก view อีกที

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFVision Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.8 (NET v2.0) - 3/29/2008
Copyright © 2003-2008 Yet Another Forum.net. All rights reserved.


Sponsored by