Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.C
cmd.CommandText = "select sys_user, year(一配_日期) as 年, 一配_公猪 as 编号, count(一配_日期) as 总配种数, count(分娩_总产仔数) As 总分娩窝数, sum(分娩_总产仔数) As 总产仔数 " & _
"f rom {母猪分娩断奶信息} where [sys_user]='" & user.Name & "' group by year(一配_日期), 一配_公猪, sys_user order by year(一配_日期), 一配_公猪 "
dt = cmd.ExecuteReader()
Tables("配种产仔分析_table1").DataSource = dt
With DataTables("配种产仔分析_Table1").DataCols
.Add("配种分娩率",Gettype(Double), " ISNULL([总分娩窝数],0) / IIF(IsNull([总配种数],0) = 0, null, IsNull([总配种数],0)) ")
.Add("产仔数/窝",Gettype(Double), " ISNULL([总产仔数],0) / IIF(IsNull([总分娩窝数],0) = 0, null, IsNull([总分娩窝数],0)) ")
End With
DataTables("配种产仔分析_Table1").DataCols("产仔数/窝").SetFormat("0.00")
DataTables("配种产仔分析_Table1").DataCols("配种分娩率").SetFormat("0.0%")
Tables("配种产仔分析_Table1").DefaultColWidth = 120
Dim Chart As WinForm.Chart
Dim Series As WinForm.ChartSeries
Chart= e.Form.Controls("Chart1")
Chart.SeriesList.Clear()
Series = Chart.SeriesList.Add()
Dim n As List(of String) = DataTables("配种产仔分析_Table1").GetValues("年")
Dim b As List(of String) = DataTables("配种产仔分析_Table1").GetValues("编号")
MessageBox.Show(1)
Series.Length = n.Count
MessageBox.Show(2)
For bi As Integer = 0 To b.Count - 1
For ni As Integer = 0 To n.Count - 1
MessageBox.Show(3)
Dim dr As DataRow = DataTables("配种产仔分析_Table1").find("[编号] = '" & b(bi) & "' and [年]= " & val(n(ni)) )
MessageBox.Show(4)
If dr IsNot Nothing Then
MessageBox.Show(5)
Series.X(ni) = n(ni)
MessageBox.Show(6)
Series.Y(ni) = dr("配种分娩率")
MessageBox.Show(7)
End If
Next
Next
老师你好,我的代码执行到第5部,就提示以下错误:蓝色的代码没错,请老师帮我看一下!
.NET Framework 版本:2.0.50727.8000
Foxtable 版本:2014.11.11.1
错误所在事件:窗口,配种产仔分析,Button1,Click
详细错误信息:
Invalid data type