Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Crystal Reports General discussion about Crystal Reports. For discussions specific to the book Professional Crystal Reports for VS.NET, please see the book discussion forum for that book.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Crystal Reports section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2005, 03:13 AM
Authorized User
 
Join Date: Dec 2004
Location: Utraula, U.P., India.
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default How use the crystal report in vb.net

i want how connect crystal report in vb.net.
if want to use crystal report then what will have to do.
are it different from vb6.0 or not

Reply With Quote
  #2 (permalink)  
Old February 26th, 2005, 03:03 AM
Registered User
 
Join Date: Feb 2005
Location: Surat, Gujarat, India.
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can programmatically pass parameter values into your Crystal Report using VB.NET code similar to this:


    Imports CrystalDecisions.CrystalReports.Engine
    Imports CrystalDecisions.Shared
    '
    ' Load the selected report file.
    '
    Dim CR As New ReportDocument
    CR.Load(strReportPath)
    '
    ' Declare the parameter related objects.
    '
    Dim crParameterDiscreteValue As ParameterDiscreteValue
    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
    Dim crParameterFieldLocation As ParameterFieldDefinition
    Dim crParameterValues As ParameterValues
    '
    ' Get the report's parameters collection.
    '
    crParameterFieldDefinitions = CR.DataDefinition.ParameterFields
    '
    ' Set the first parameter
    ' - Get the parameter, tell it to use the current values vs default value.
    ' - Tell it the parameter contains 1 discrete value vs multiple values.
    ' - Set the parameter's value.
    ' - Add it and apply it.
    ' - Repeat these statements for each parameter.
    '
    crParameterFieldLocation = crParameterFieldDefinitions.Item("StartDate")
    crParameterValues = crParameterFieldLocation.CurrentValues
    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
    crParameterDiscreteValue.Value = strStartDate
    crParameterValues.Add(crParameterDiscreteValue)
    crParameterFieldLocation.ApplyCurrentValues(crPara meterValues)
    '
    ' Set the Crytal Report Viewer control's source to the report document.
    '
    CrystalReportViewer.ReportSource = CR


If your report's DataSource is a .NET DLL DO NOT set the ReportDocument's DataSource property programatically as in the code below. However, if the DataSource is an XML Schema (.xsd) file you must set it prior to setting your parameters.


    cr.SetDataSource(DS.Tables("Customer"))


If your report's DataSource is a .NET DLL as shown here and the public functions that return the datatables available to your report where changed to require parameters, as illustrated below, the parameters can be set as just described.


    Public Function Customers(theStartDate As String) As DataTable


If the parameters were added to your Crystal Report by clicking the Parameter Fields node in the Crystal IDE's Field Explorer they can be set using the following code:


    Dim cr As New ReportDocument
    cr.Load(strReportPath)
    cr.SetDataSource(DS.Tables("Customers"))
    cr.SetParameterValue("StartDate", strMyParmValue)
    CrystalReportViewer.ReportSource = cr
Reply With Quote
  #3 (permalink)  
Old May 17th, 2013, 10:39 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default View Crystal Reports from .Net

I am using code like the following to view Crystal Reports from .Net

Code:
Public Class Form1


    
    Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
        Dim oApp = New CRAXDRT.Application
        Dim oReport As CRAXDRT.Report
        oReport = oApp.OpenReport("C:\temp\reportname.rpt", 1)

        With oReport.Database.Tables(1).ConnectionProperties
            .DeleteAll()
            .Add("Provider", "SQLOLEDB.1")
            .Add("User ID", "UserName")
            .Add("Password", "Password")
            .Add("Initial Catalog", "Database")
            .Add("DSN", "DSNName")


        End With

        AxCrystalActiveXReportViewer1.ReportSource = oReport
        AxCrystalActiveXReportViewer1.ViewReport()






    End Sub

    Private Sub AxCrystalActiveXReportViewer1_Enter(sender As System.Object, e As System.EventArgs) Handles AxCrystalActiveXReportViewer1.Enter

    End Sub
End Class
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple report and crystal report in vb.net saket123 .NET Framework 2.0 0 August 13th, 2008 06:55 AM
vb.net And Crystal Report Tata .NET Framework 1.x 0 June 13th, 2008 10:16 PM
Crystal Report and VB.NET rupesh_india Beginning VB 6 0 August 19th, 2006 08:47 AM
Crystal Report in VB.net anandf Crystal Reports 1 March 13th, 2006 01:21 PM
Crystal Report in VB.Net mangeshshelar Crystal Reports 1 January 13th, 2005 09:41 AM



All times are GMT -4. The time now is 09:07 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.