日期:2014-05-17 浏览次数:20527 次
SqlConnection sqlcon; string sqlstr = @"SELECT OrderDetails.ProductID AS 产品编码, Product.ProdName AS 产品名称 , Product.Unit AS 单位 , OrderDetails.Price AS 单价, OrderDetails.QTY AS 数量, OrderDetails.QTY*OrderDetails.Price AS 总金额, From OrderDetails left join Product on OrderDetails.ProductID=product.productid Order BY ProductID "; this.SqlDataSourceDetails.SelectCommand = sqlstr; this.SqlDataSourceDetails.DataBind(); sqlcon = new SqlConnection(connectionString); SqlDataAdapter da = new SqlDataAdapter(sqlstr, sqlcon); DataSet ds = new DataSet(); sqlcon.Open(); da.Fill(ds, "OrderDetails"); GridView1.DataSourceID = ""; GridView1.DataSource = ds; GridView1.DataBind();