GridReport 5.0 报表的使用
来源:互联网 发布:sql默认实例 编辑:程序博客网 时间:2024/06/07 18:28
连接:
'GripReport 连接语句 GRID Report 连接到的数据库
Public ConnectStringForGridReport As String = "Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=sa;Initial Catalog=DBName;Data Source=SQL Server;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=**PC003;Use Encryption for Data=False;Tag with column collation when possible=False"
引用:
Interop.grproLib,AxInterop.grproLib
定义:
Imports grproLib
Private Report0 As New GridppReport
使用:
Report0.LoadFromFile("" & Application.StartupPath & "\gridreport.grf")
Report0.DetailGrid.Recordset.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\10.10.10.10\IQCDatabase\Access2003.mdb;Password=;Jet OLEDB:Database Password='password'"
Report0.DetailGrid.Recordset.QuerySQL = "Select * From "'"
'设置报表查询显示器控件的关联报表对象
AxGRDisplayViewer1.Report = Report0
'启动报表运行
Report.DetailGrid.FixCols = 2 '锁定为两行
AxGRDisplayViewer1.Start()
第二种:多条记录的情况
Frm员工信息报表.AxGRDisplayViewer1.Stop()
AddHandler Report.FetchRecord, AddressOf SimpleEmployeeQuery '指针 + 地址 这一句可以不加
Report.LoadFromFile(Application.StartupPath & "\reports\GridReport.grf")
Report.PrepareRecordset() '这句一定要加 否则出错
Private Structure MatchFieldPairType
Public grField As IGRField
Public MatchColumnIndex As Integer
End Structure '结构体
Public Shared Sub FillRecordToReport(ByVal Report As IGridppReport, ByVal dt As DataTable)
Dim MatchFieldPairs() As MatchFieldPairType
ReDim MatchFieldPairs(Math.Min(Report.DetailGrid.Recordset.Fields.Count, dt.Columns.Count))
'根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
Dim MatchFieldCount As Integer
MatchFieldCount = 0
Dim I As Integer
For I = 0 To dt.Columns.Count - 1
Dim fld As IGRField
For Each fld In Report.DetailGrid.Recordset.Fields
If String.Compare(fld.Name, dt.Columns.Item(I).ColumnName, True) = 0 Then
MatchFieldPairs(MatchFieldCount).grField = fld
MatchFieldPairs(MatchFieldCount).MatchColumnIndex = I
MatchFieldCount = MatchFieldCount + 1
Exit For
End If
Next fld
Next
'将 DataTable 中的每一条记录转储到Grid++Report 的数据集中去
Dim dr As DataRow
For Each dr In dt.Rows
Report.DetailGrid.Recordset.Append()
For I = 0 To MatchFieldCount - 1
If Not dr.IsNull(MatchFieldPairs(I).MatchColumnIndex) Then
MatchFieldPairs(I).grField.Value = dr.Item(MatchFieldPairs(I).MatchColumnIndex)
End If
Next
Report.DetailGrid.Recordset.Post()
Next
End Sub 'DataTable的GridReport的填充方式
Public Shared Sub FillRecordToReport(ByVal Report As IGridppReport, ByVal dr As SqlDataReader)
Dim MatchFieldPairs() As MatchFieldPairType
ReDim MatchFieldPairs(Math.Min(Report.DetailGrid.Recordset.Fields.Count, dr.FieldCount))
'根据字段名称与列名称进行匹配,建立DataReader字段与Grid++Report记录集的字段之间的对应关系
Dim MatchFieldCount As Integer
MatchFieldCount = 0
Dim i As Integer
For i = 0 To dr.FieldCount - 1
Dim fld As IGRField
For Each fld In Report.DetailGrid.Recordset.Fields
If String.Compare(fld.RunningDBField, dr.GetName(i), True) = 0 Then
MatchFieldPairs(MatchFieldCount).grField = fld
MatchFieldPairs(MatchFieldCount).MatchColumnIndex = i
MatchFieldCount = MatchFieldCount + 1
Exit For
End If
Next fld
Next
'Loop through the contents of the OleDbDataReader object.
'将 DataReader 中的每一条记录转储到Grid++Report 的数据集中去
Report.DetailGrid.Recordset.Append()
For i = 0 To MatchFieldCount - 1
If Not dr.IsDBNull(MatchFieldPairs(i).MatchColumnIndex) Then
MatchFieldPairs(i).grField.Value = dr.GetValue(MatchFieldPairs(i).MatchColumnIndex)
End If
Next
Report.DetailGrid.Recordset.Post()
End Sub 'DataReader的GridReport的填充方式
客户端: 注册
regsvr32 grdes50.dll
regsvr32 gregn50.dll
- GridReport 5.0 报表的使用
- 锐浪GridReport交叉报表
- VB为报表GridReport设定显示时间
- GridReport 排序
- 水晶报表的使用:
- 水晶报表的使用
- rdlc报表的使用
- 水晶报表的使用
- chinaexcel报表的使用
- 水晶报表(子报表的使用)
- GridReport导出 Excel 产生很多细小的列与行(合并列与合并行)
- 报表设计器的使用
- 水晶报表的使用技巧
- 水晶报表使用的例子
- 水晶报表的简单使用
- 水晶报表的简单使用
- .net水晶报表的使用
- 水晶报表的使用技巧
- listview的用法
- 栈和队列
- Ruby Watir自动化环境搭建
- 解决SSL网页提示的不安全信息
- stdafx.cpp"编译引起的C2859、C1083、LNK2001错
- GridReport 5.0 报表的使用
- Launchpad Capacitive Sensing
- OpenGIS相关概念和开源软件
- .NET保护图片防盗链技术思路
- 关于thinkpad t400 安装Ubuntu 12.04 后的几个问题
- Thread interrupt() 方法的使用
- CreateFileMapping()的使用心得
- 水题不水
- 数学建模方法