Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > Crystal Reports
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 14th, 2004, 01:21 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default crystal Reports in asp.net page

Reqd help urgently::::

  I want to know how to create a crystal report from asp.net page using crystalreportviewer .Now this works fine. But the problem is
1.How to pass runtime parameter to the crystal report & get selective records displayed

   eg. I want the details of John alone from the Employee table in SQL server database.I am using vb.net as code file
   Pl help asap;
Would be grateful as project deadlines are close

 
Old July 14th, 2004, 01:48 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

http://p2p.wrox.com/topic.asp?TOPIC_ID=6389

Always:),
Hovik Melkomian.
 
Old August 17th, 2004, 08:03 AM
rsk rsk is offline
Registered User
 
Join Date: Aug 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi

i use a dataset to set up the query and then pass the dataset to the crystal report viewer:

Dim newRpt As GeneralReport
        newRpt = New GeneralReport

        Make_con() 'sub that sets the connection to sql
        sqlCommand.Connection = sqlCon
        strQuery = "Select * From tableName"

        Dim sqlDA As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter(strQuery, sqlCon)

        strWhere = ""

        'SET UP THE QUERY HERE

        strQuery = strQuery & strWhere
        sqlDA.SelectCommand.CommandText = strQuery
        Dim sqlDS As New DataSet
        sqlDA.Fill(sqlDS)
        Me.cvReport.Visible = True
        newRpt.SetDataSource(sqlDS.Tables(0))
        cvReport.ReportSource = newRpt
        sqlCon.Close()

hope this helps u.

 
Old August 20th, 2004, 01:08 AM
Registered User
 
Join Date: Aug 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

you ca create a crystal report in asp.net by

1. Create a new web form by right clicking your project and select add web form. name the form.

2. From a tool box drag and drop crystalreportviewer on to the form.
3. Add ur existing crystal report to your project by righting ur project and select add existing item choose ur report.

4. Drag and drop reportdocument from component in the tool box.
A pop window shows ur added report and all the exisiting report.
choose ur report and click ok. Add one textbox(txtbox) to hold your parameter.

5. Add the below.


        ' Binding by report object.
        'CRobj is a report object either u can pass the path or pass the class
        'testorganization_para() is the automatically generated class of report.

        Dim CRobj As New ReportDocument()
        Dim CRdiscretevalue As New CrystalDecisions.Shared.ParameterDiscreteValue()
        Dim CRParameterFieldDefinitions As ParameterFieldDefinitions
        Dim CRParameterFieldLocation As ParameterFieldDefinition
        Dim CRparametervalues As New CrystalDecisions.Shared.ParameterValues()

        ' Get report parameter's collection

        CRobj = New testorganization_para()
        faccrystalreport.ReportSource = CRobj ' faccrystalreport is a crystalreportviewer
        CRParameterFieldDefinitions = CRobj.DataDefinition.ParameterFields
        CRParameterFieldLocation = CRParameterFieldDefinitions.Item("organization city")
        CRparametervalues = CRParameterFieldLocation.CurrentValues

        Dim CRParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue()
'txtbox is your textbox id from where you are passing ur parameter to the report.
        CRParameterDiscreteValue.Value = txtbox.text
        CRparametervalues.Add(CRParameterDiscreteValue)
        CRParameterFieldLocation.ApplyCurrentValues(CRpara metervalues)
        '
        ' Set the Crytal Report Viewer control's source to the report document.
        '

        faccrystalreport.ReportSource = CRobj

        'connection string and table information declaration

        Dim tablelongoninfo As New CrystalDecisions.Shared.TableLogOnInfo()
        Dim con As New CrystalDecisions.Shared.ConnectionInfo()

        Dim CRdatabase As Database
        Dim CRtable As Tables
        Dim cretable As Table

' Enter ur server name and databasename here
        con.ServerName = ""
        con.DatabaseName = ""
        con.UserID = "sa"
        con.Password = ""
        CRdatabase = CRobj.Database
        CRtable = CRdatabase.Tables

        For Each cretable In CRtable

            tablelongoninfo = cretable.LogOnInfo
            tablelongoninfo.ConnectionInfo = con
            cretable.ApplyLogOnInfo(tablelongoninfo)

        Next

        faccrystalreport.ReportSource = CRobj
'---------------------------------------------------------------------


this will work.

Please let me know about it.

thank you




 
Old March 7th, 2006, 04:26 PM
Registered User
 
Join Date: Mar 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I am very new to asp.net and have a chance to look ur code for asp.net and crystal reports. Can you please tell me the following line in your code?

CRParameterFieldLocation = CRParameterFieldDefinitions.Item("organization city")
What is that "organization city"? Is it a database field?

Thanks! Your help will be appreciated.

Quote:
quote:Originally posted by shamala
 hi,

you ca create a crystal report in asp.net by

1. Create a new web form by right clicking your project and select add web form. name the form.

2. From a tool box drag and drop crystalreportviewer on to the form.
3. Add ur existing crystal report to your project by righting ur project and select add existing item choose ur report.

4. Drag and drop reportdocument from component in the tool box.
A pop window shows ur added report and all the exisiting report.
choose ur report and click ok. Add one textbox(txtbox) to hold your parameter.

5. Add the below.


        ' Binding by report object.
        'CRobj is a report object either u can pass the path or pass the class
        'testorganization_para() is the automatically generated class of report.

        Dim CRobj As New ReportDocument()
        Dim CRdiscretevalue As New CrystalDecisions.Shared.ParameterDiscreteValue()
        Dim CRParameterFieldDefinitions As ParameterFieldDefinitions
        Dim CRParameterFieldLocation As ParameterFieldDefinition
        Dim CRparametervalues As New CrystalDecisions.Shared.ParameterValues()

        ' Get report parameter's collection

        CRobj = New testorganization_para()
        faccrystalreport.ReportSource = CRobj ' faccrystalreport is a crystalreportviewer
        CRParameterFieldDefinitions = CRobj.DataDefinition.ParameterFields
        CRParameterFieldLocation = CRParameterFieldDefinitions.Item("organization city")
        CRparametervalues = CRParameterFieldLocation.CurrentValues

        Dim CRParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue()
'txtbox is your textbox id from where you are passing ur parameter to the report.
        CRParameterDiscreteValue.Value = txtbox.text
        CRparametervalues.Add(CRParameterDiscreteValue)
        CRParameterFieldLocation.ApplyCurrentValues(CRpara metervalues)
        '
        ' Set the Crytal Report Viewer control's source to the report document.
        '

        faccrystalreport.ReportSource = CRobj

        'connection string and table information declaration

        Dim tablelongoninfo As New CrystalDecisions.Shared.TableLogOnInfo()
        Dim con As New CrystalDecisions.Shared.ConnectionInfo()

        Dim CRdatabase As Database
        Dim CRtable As Tables
        Dim cretable As Table

' Enter ur server name and databasename here
        con.ServerName = ""
        con.DatabaseName = ""
        con.UserID = "sa"
        con.Password = ""
        CRdatabase = CRobj.Database
        CRtable = CRdatabase.Tables

        For Each cretable In CRtable

            tablelongoninfo = cretable.LogOnInfo
            tablelongoninfo.ConnectionInfo = con
            cretable.ApplyLogOnInfo(tablelongoninfo)

        Next

        faccrystalreport.ReportSource = CRobj
'---------------------------------------------------------------------


this will work.

Please let me know about it.

thank you




 
Old December 31st, 2006, 11:07 AM
Registered User
 
Join Date: Dec 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi
I've been trying to create report but i found this problem

        Dim rpt As New CrystalReport()
   *** rpt.setDataSource(DA) ***
        CrystalReportViewer1.ReportSource = rpt
        conn.Close()

The report instance that i've create doesn't have method 'setDataSource', so error occurs when i run the application.

Please help,
Thanks in advance






Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET 1.1,VB.NET,crystal reports, SQl server gvi Crystal Reports 1 September 11th, 2008 02:55 AM
Crystal Reports in asp.net 1.1 Pramods ASP.NET 1.0 and 1.1 Professional 0 June 14th, 2007 08:27 AM
Crystal Reports in ASP.NET bmains Crystal Reports 2 March 27th, 2004 04:45 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.