加好友 发短信
等级:幼狐
帖子:188
积分:1947
威望:0
精华:0
注册:2008/9/23 22:10:00
|
对于外部数据表的统计 Post By:2009/6/19 15:54:00 [显示全部帖子]
Dim doc As New PrintDoc Dim rt As New prt.RenderTable Dim cmd As New SQLCommand '定义一个SQL命令 Dim dt As DataTable '定义一个数据表变量 Dim Count As Integer = 0 cmd.CommandText = "Select 产品,Count(日期) As 订单数,Sum(数量) As 数量,Sum(金额) As 金额 From {订单} Group By 产品" dt = cmd.ExecuteReader() '生成一个临时表 For Each Col AS DataCol In Dt.DataCols rt.Cells(0,Count).Text = Col.Name For r As integer = 0 To dt.DataRows.Count - 1 rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name) Next Count = Count + 1 Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线 rt.CellStyle.Spacing.All = 1 '内容距离网格线1毫米 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中 doc.Body.Children.Add(rt) doc.Preview()
以上代码是否适用于外部数据表啊,我执行时,提示未将对象引用到实例。。。
|
|