怎么把一个值写到dateset的一个字段里
1个回答
展开全部
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();
实现销售额统计 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();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询