C#中将数据集(dateset)查询生成的表中的某个列的值取出来(这里将查询到的SUM值取出)
实现销售额统计
SqlConnection MyConnection = new SqlConnection();
MyConnection.ConnectionString = global::MySale.Properties.Settings.Default.MySaleConnectionString;
MyConnection.Open();
string MySQL = "SELECT SUM(dbo.销售出库明细视图.金额) AS MONEY FROM 销售出库明细视图 WHERE 出库日期 BETWEEN '" + this.销售开始日期DateTimePicker.Value.ToString() + "' AND '" + this.销售结束日期DateTimePicker.Value.ToString() + "' AND 商品名称 LIKE '" + this.商品名称ComboBox.Text + "'";
SqlDataAdapter MyAdapter =new SqlDataAdapter(MySQL,MyConnection);
DataSet dataset = new DataSet();
dataset.Tables.Add("money");
MyAdapter.Fill(dataset, "money");
销售额统计textBo.Text = dataset.Tables["money"].Rows[0]["MONEY"].ToString();
dataset.Tables["PersonInfo"].Rows[0]["age"].ToString();