日期:2014-05-18 浏览次数:20600 次
SqlConnection con = dataOperate.createCon(); con.Open(); DataSet ds; sql1 = "select userid,moterid,startdate,startengy from UserDayEngy where userid='"+ strUser +"' and moterid='" + strMoter + "'and datetime='"+startDate+"'"; SqlDataAdapter sda = new SqlDataAdapter(sql1, con); ds = new DataSet(); sda.Fill(ds, "singlemoter"); sql2 = "select enddate,endengy from UserDayEngy where userid='" + strUser + "' and moterid='" + strMoter + "'and datetime='" + endDate + "'"; SqlDataAdapter sda1 = new SqlDataAdapter(sql2, con); sda1.Fill(ds, "Singlemoter"); MonthsElectricityNumber.DataSource = ds; BoundField field; field = new BoundField(); field.DataField="userid"; field.HeaderText = "用户编号"; MonthsElectricityNumber.Columns.Add(field); field = new BoundField(); field.DataField = "moterid"; field.HeaderText = "电表编号"; MonthsElectricityNumber.Columns.Add(field); field = new BoundField(); field.DataField = "startdate"; field.HeaderText = "起始日期"; MonthsElectricityNumber.Columns.Add(field); field = new BoundField(); field.DataField = "startengy"; field.HeaderText = "起始电量"; MonthsElectricityNumber.Columns.Add(field); field = new BoundField(); field.DataField = "enddate"; field.HeaderText = "终止日期"; MonthsElectricityNumber.Columns.Add(field); field = new BoundField(); field.DataField = "endengy"; field.HeaderText = "终止电量"; MonthsElectricityNumber.Columns.Add(field); MonthsElectricityNumber.DataBind();