以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- fill进来的表,cmd.CommandText能引用吗? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=121354) |
-- 作者:yetle -- 发布时间:2018/7/4 14:50:00 -- fill进来的表,cmd.CommandText能引用吗? 窗口加载,报错 Microsoft Jet 数据库引擎找不到输入表或查询 \'~TMPCLP日产量分析_table2\'。 确定它是否存在,以及它的名称的拼写是否正确。AfterLoad代码如下: e.Form.Controls("TextBox1").text=year(Date.Today) e.Form.Controls("TextBox2").text=Month(Date.Today) If Forms("日产量分析").Opened() Dim t As Table = Tables("日产量分析_table2") t.Fill(" select A.MakeGro as 班组, Sum( isnull(C.Qty,0)) as 数量,DATEPART(year,d.Workdate)as 年,DATEPART(month,d.Workdate)as 月,D.ArtGD as 交接工段 f rom PQ_Convert_Main d left join PQ_Convert_List C ON d.ID=C.UpID left join PQ_Main A on c.Orderno=a.OrderNo left join bai_ftyno E ON a.ftyno=e.ftyno where ArtGD=\'车间转QC\' and A.MakeGro is not null group by A.MakeGro, D.ArtGd,d.Workdate order by A.MakeGro " , "鼎邦系统",True) End If Dim tB As Table = Tables("日产量分析_table2") With Tables("日产量分析_table2") If .Current Is Nothing Then tB.Filter = "False" Else tB.Filter = "[年] = " & Date.Today.year & " and [月] = " & Date.Today.Month End If End With Dim dt As DataTable \'定义一个数据表变量 Dim cmd As New SQLCommand \'定义一个SQL命令 cmd.CommandText = "Select 班组,Sum(数量) As 数量 F rom {日产量分析_table2} Group By 班组" dt = cmd.ExecuteReader() Dim Chart As New ChartBuilder \'定义一个图表变量 Dim Series As WinForm.ChartSeries \'定义一个图系变量 Chart.VisualEffect = True \'加上这一行,让你的图表更漂亮 Chart.ChartType = ChartTypeEnum.Bar \'图表1类型该为Bar(条形) \' Chart.ChartType2 = ChartTypeEnum.XYPlot \'图表2类型该为线形 Chart.DataTable = dt \'设置绑定表 Chart.SeriesList.Clear() \'清除图表原来的图系 Chart= Forms("日产量分析").Controls("Chart2") \' 引用窗口中的图表 Series = Chart.SeriesList.Add() \'增加一个图系 Series.Text = "数量" Series.X.DataField = "班组" \'X轴绑定到月份列 Series.Y.DataField = "数量" \'Y轴绑定到数量列 \' Series = Chart.SeriesList2.Add() \'给图表2增加一个图系 \' Series.Text = "金额" \' Series.X.DataField = "产品" \'X轴绑定到月份列 \' Series.Y.DataField = "金额" \'Y轴绑定到数量列 Chart.LegendVisible = True \'显示图列 Chart.LegendCompass= CompassEnum.South \'图列显示在南方(底端) Chart.AxisY.Text = "数量" \' Chart.AxisY2.Text = "金额" Chart.PrintWidth = 150 \'图表宽度为150毫米 Chart.PrintHeight = 100 \'图标高度为100毫米 |
-- 作者:有点甜 -- 发布时间:2018/7/4 16:18:00 -- 不可以直接使用。
如果要使用,你要拷贝整个sql语句到下面红色代码中
Select 班组,Sum(数量) As 数量 From (sql语句) as test Group By 班组 |