vb中sql查询语句
sql语句是这样写的sqltxt="selecth_dateas发生时间,sum(l_time)as持续总时间,sum(area_disa)as受灾总面积fromdata...
sql语句是这样写的
sqltxt = "select h_date as 发生时间,sum(l_time) as 持续总时间,sum(area_disa) as 受灾总面积 from datainfo where h_date like '%" & st.Text & "%' group by h_date"
但是下面这段代码
rs.Open sqltxt, conn, adOpenKeyset, adLockReadOnly
MsgBox rs.RecordCount
If rs.RecordCount = 0 Then Exit Function
With MSChart1
'设置图形显示的类型
.RowCount = rs.RecordCount '设置显示的图形数
.ColumnCount = rs.RecordCount '设置标签数
.FootnoteText = "气象查询系统统计图表"
.TitleText = mscinfo & "统计图"
.ShowLegend = True
For K = 1 To .Plot.SeriesCollection.Count
.Plot.SeriesCollection(K).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
Next
For j = 1 To rs.RecordCount
If rs.EOF Then Exit Function
.Row = j
.RowLabel = rs(j - 1).Value
For i = 1 To rs.RecordCount
.Column = i
.ColumnLabel = "党" & i '
.Data = rs(i).Value '填充当前活动列的值
rs.MoveNext
Next
'rs.MoveNext
Next
End With
提示
.Data = rs(i).Value '填充当前活动列的值
这一行错误,原因是 无效使用null 但是调试的时候,data是有值的
意思就是调试的时候,data可以看到是有具体的数字的,但是后面的rs这个值就是null
不知道是为什么,请大侠帮帮忙
弄好了追加50分 展开
sqltxt = "select h_date as 发生时间,sum(l_time) as 持续总时间,sum(area_disa) as 受灾总面积 from datainfo where h_date like '%" & st.Text & "%' group by h_date"
但是下面这段代码
rs.Open sqltxt, conn, adOpenKeyset, adLockReadOnly
MsgBox rs.RecordCount
If rs.RecordCount = 0 Then Exit Function
With MSChart1
'设置图形显示的类型
.RowCount = rs.RecordCount '设置显示的图形数
.ColumnCount = rs.RecordCount '设置标签数
.FootnoteText = "气象查询系统统计图表"
.TitleText = mscinfo & "统计图"
.ShowLegend = True
For K = 1 To .Plot.SeriesCollection.Count
.Plot.SeriesCollection(K).DataPoints(-1).DataPointLabel.LocationType = VtChLabelLocationTypeAbovePoint
Next
For j = 1 To rs.RecordCount
If rs.EOF Then Exit Function
.Row = j
.RowLabel = rs(j - 1).Value
For i = 1 To rs.RecordCount
.Column = i
.ColumnLabel = "党" & i '
.Data = rs(i).Value '填充当前活动列的值
rs.MoveNext
Next
'rs.MoveNext
Next
End With
提示
.Data = rs(i).Value '填充当前活动列的值
这一行错误,原因是 无效使用null 但是调试的时候,data是有值的
意思就是调试的时候,data可以看到是有具体的数字的,但是后面的rs这个值就是null
不知道是为什么,请大侠帮帮忙
弄好了追加50分 展开
3个回答
展开全部
.Data = rs(i).Value改成
if isnull(rs.fields(i).value)= false then .Data = rs(i).Value
对变量赋"Null"值会出错,先要去除"Null"项的值
if isnull(rs.fields(i).value)= false then .Data = rs(i).Value
对变量赋"Null"值会出错,先要去除"Null"项的值
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
For i = 1 To rs.RecordCount 改成 For i = 0 To 2
参考资料: 尝试
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询