对面的高手看过来

ShallowShrimp 2003-06-24 02:39:29
各位高手:
在VB6+Crystal Report7中如何把ADO数据集传给水晶报表?即adodc与crystal report如何搭配使用?
请各位不惜赐教,希望能详细解释清楚,谢了!
...全文
45 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ShallowShrimp 2003-06-25
  • 打赏
  • 举报
回复
各位,有没有核心简短点的代码?
wangbm 2003-06-24
  • 打赏
  • 举报
回复
设置报表的DATASOURCE=记录击
Colin_Qin 2003-06-24
  • 打赏
  • 举报
回复
crystal report7 我没用过。我用过8与8.5。其作法是这样的。

一:In this step, you will add the references, components, forms, and controls for the application.

1 Create a new Standard EXE project.

2 Add the following components to the project:

Crystal Reports Viewer Control
Embeddable Crystal Reports 8.5 Designer Control
Microsoft Common Dialog 6.0
Microsoft Tabbed Dialog Control 6.0 (Sp4).

3 Add the following reference to the project:

Crystal Reports 8.5 ActiveX Designer Design and Runtime Library.

Note: See Programming the Crystal Report Viewers for more information.

4 Add the following controls from the Toolbox to the form:

three CommandButton controls
Common Dialog (Microsoft Common Dialog Control 6.0)
SSTab1 (Microsoft Tabbed Dialog Control 6.0 (SP4))
CRDesignerCtrl (Embeddable Crystal Reports 8.5 Designer Control)
CRViewer (Crystal Report Viewer Control).

5 Set the properties for the form and the controls:

Form1 (Main form for the application):

Name = frmMain

Caption = Embeddable Crystal Reports 8.5 Designer Control Sample

Height = 8265

Width = 10815

SStab (Tabbed control containing the Embeddable Designer and Report Viewer controls):

Note: Click the tabs on SSTab1 to access the separate Caption properties.

Name = SSTab1

Tabs = 2

Tab1 Caption = Design

Tab2 Caption = Preview

Enabled = False

Height = 7600

Left = 0

Tab Height = 300

Top = 130

Width = 10825

CRDesignerCtrl1 (Designs and edits reports):

Note: Place the control on the tab labeled 揇esigner.?

Name = CRDesignerCtrl1

Height = 6540

Left = 0

Top = 0

Width = 10325

CRViewer (Views reports):

Name = CRViewer1

Height = 10340

Left = 120

Top = 360

Height = 6600

CommonDialog (Creates an Open dialog to select reports):

Name = CommonDialog1

Filter = Crystal Reports |*.rpt

Button1 (Creates a new report):

Name = cmdNewReport

Caption = &New Report

Left = 120

Top = 7850

Button2 (Opens an existing report):

Name = cmdOpenReport

Caption = &OpenReport

Left = 1950

Top = 7850

Button3 (Closes the form and exits the application):

Name = cmdExit

Caption = E&xit

Left = 9030

Top = 7850

二:In this step you will add the code to:

create a new report

create an Open dialog box to open an existing report

set the report object to CRDesignerCtrl1 and view the report in design mode

set the report object to CRViewer1, set the zoom level, and view the report

refresh the report when switching from the Designer tab to the Viewer tab on the Microsoft Tabbed Dialog Control.

1 Type or insert the sample code below into the code module of frmMain.

2 Once you have added the code, on the Run menu click Start to run the application.

Note: Error handling is not included in the code samples.

Option Explicit

Dim m_Application As New CRAXDDRT.Application

Dim m_Report As CRAXDDRT.Report

' *************************************************************

'DisplayReport is a procedure that

' - Enables the Tab control the first time a report is created

' or opened.

' - Sets the report object to the Embeddable Designer(CRDesigner1).

' - Disables the Help menu in the Embeddable Designer.

' - Sets the report object to the Crystal Report Viewer Control

' (CRViewer1).

' - Sets the Crystal Reports Viewer to view the report.

'

Public Sub DisplayReport()

' Enable the tab control if disabled.

If SSTab1.Enabled = False Then SSTab1.Enabled = True

' Set the Report Object

CRDesignerCtrl1.ReportObject = m_Report



' Note----------------

' Set all other properties for CRDesignerCtrl1 after setting the

' ReportObject property

' --------------------



' Disable the Help menu

CRDesignerCtrl1.EnableHelp = False

' Set the report source

CRViewer1.ReportSource = m_Report

' Set the viewer to view the report

CRViewer1.ViewReport

' Set the zoom level to fit the page

' to the width of the viewer window

CRViewer1.Zoom 1

End Sub

' *************************************************************

Private Sub Form_Load()

'Set the tab control to display the Designer tab

'when the form is loaded

SSTab1.Tab = 0

End Sub

' *************************************************************

Private Sub SSTab1_Click(PreviousTab As Integer)

' Refresh the report when clicking Preview,

' without refreshing the data from the server.

If PreviousTab = 0 Then CRViewer1.RefreshEx False

End Sub

' *************************************************************

' Create a new report and display it in the Embeddable Designer

'

Private Sub cmdNew_Click()

' Set the report object to nothing

Set m_Report = Nothing

' Create a new report

Set m_Report = m_Application.NewReport

' Call DisplayReport to set the report to the Embeddable Designer

' and the Crystal Report Viewer and then display the report in the

' Embeddable Designer.

Call DisplayReport

End Sub

' *************************************************************

' Use the Microsoft Common Dialog control to open a report.

'

Private Sub cmdOpen_Click()

CommonDialog1.CancelError = True

On Error GoTo errHandler

' Display the open dialog box

CommonDialog1.ShowOpen

' Set the report object to nothing

Set m_Report = Nothing

' Open the selected report

Set m_Report = m_Application.OpenReport(CommonDialog1.FileName, 1)

' Call DisplayReport to set the report to the Embeddable Designer

' and the Crystal Report Viewer

Call DisplayReport

Exit Sub

errHandler:

'User cancelled dialog

End Sub

' *************************************************************

Private Sub cmdAbout_Click()

frmAbout.Show vbModal

End Sub

' *************************************************************

Private Sub cmdExit_Click()

Unload Me

End Sub


三:
In this step you will:

create and design a new report in the Embeddable Designer

view the report and any changes made to the report

open and edit an existing report in the Embeddable Designer

view the report and any changes made to the report.

1 With the application running, click New Report.

An empty report will appear in the Embeddable Designer.

Note: The interface for the Embeddable Designer is the same one used for ActiveX Designer reports created in the Microsoft Visual Basic IDE with the Crystal Reports Report Designer Component.

2 Design a new report to view.

If you are not familiar with the designer environment, see Designing reports in the Embeddable Designer for a step-by-step procedure on creating a simple report off the Xtreme Sample Database ODBC data source.

3 Click Preview to view the report in the Crystal Report Viewer.

4 Click Design and make some changes to the report. Then click Preview to see the changes in the Crystal Report Viewer.

5 Click Open.

6 In the Open dialog box select one of the sample reports and click Open to view the report in the Embeddable Designer.

7 Click Preview to view the report in the Crystal Report Viewer.

8 Click Design and make some changes to the report. Then click Preview to see the changes in the Crystal Report Viewer.

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧