Typical method of printing Crystal Report by VB 2

Source: Internet
Author: User
Tags odbc connection
Program | print | Crystal Report
Describe:

This paper introduces another popular method of printing Crystal Report by VB program.



Environment: MS SQL SERVER 2000/vb6/crystal REPORT8.5



Steps

1: Establish an ODBC connection



2: Create a report file for Crystal Reports



3: Loading the Microsoft ActiveX Data Objects Library to the references of the project



4. Create VB Design (Designer), through the open existing file to load Crystal Report file.

If the report conditions from the screen input need to write some simple program, for example

Dim adors as ADODB. Recordset

Private Sub report_initialize ()



sql$ = "SELECT * from view_xxxx where XXXX"

' re-obtain the Where condition ' from the screen



Set adors = CreateObject ("Adodb.recordset")

Adors.open sql$, "PROVIDER=MSDASQL.1; Persist security Info=false;data Source=odbc_sales ", adOpenKeyset, adLockBatchOptimistic

Database.setdatasource adors

End Sub



Private Sub report_terminate ()

Set adors = Nothing

End Sub



5: Create a VB screen (Form), add crystal the viewer control

Some simple programs, examples

Dim rptreportname as Rpt_reportname ' Rptreportname is name of designer

Private Sub Form_Load ()

Crviewer1.reportsource = Rptreportname

Crviewer1.viewreport

End Sub



Summarize:

This method realizes the control of the VB program to the Crystal report, but it is not as effective as the previous one in the aspect of scalability, the format of any report needs to be compiled the whole project L






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.