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 | 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 November 1st, 2006, 10:46 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default VB.NET - creating a CR report at run time

Hi,

I have been trying to create crystal reports at run time through VB.NET. What I mean by this is writing the all the code to build a report in VB.NET then passing it to CR Viewer. I am trying to create a report generator where a user would choose columns, filters and group-by's from a VB.NET GUI then run the report based on the user's selection.

I need to send a SQL Query to cyrstal reports and then add the selected columns all at runtime and I haven't a clue how to do this. After searching the internet for a while help seems to be very limited for this problem. I've found small bits of code but it's mainly for ASP or vb6 and I can't get any of it to work!!

I am running CR 9, the version that comes with Visual Studio 2005 and the data is stored in a sybase database (sql based).

If anyone has been able to do this or something similar which could help me, please post some code!!!

Thanks for your help in advance.

Jimbo.
Reply With Quote
  #2 (permalink)  
Old November 7th, 2006, 12:21 PM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'll reply to my own post seen as no-one else has :(

I'm quite sure many people have this problem...

I found out what the problem was - You need a lisence to create Custom reports at runtime. Using the following working code vb.net told me this:


    Dim app As New CRAXDRT.Application
    Dim repdoc As CRAXDRT.Report



    Private Sub Form2_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        repdoc = app.NewReport
        'repdoc = New CRAXDRT.Report

        ' Open the data connection
        Dim ADOConnection As New ADODB.Connection
        ADOConnection.Provider = "ASAProv"
        ADOConnection.ConnectionString = "Provider=MSDASQL.1;Persist Security Info=False;Data Source=DOB"
        ADOConnection.CursorLocation = ADODB.CursorLocationEnum.adUseClient

        ' Create a new instance of an ADO command object
        Dim ADOCommand As New ADODB.Command
        ' ADOCommand.ActiveConnection = New ADODB.Connection
        ADOCommand.CommandText = "Customer"
        ADOCommand.CommandType = ADODB.CommandTypeEnum.adCmdTable

        ' Add the data source (patient table) to the report
        repdoc.Database.AddADOCommand(ADOConnection, ADOCommand.CommandText)
        'Add a title to the report
        repdoc.Sections(1).AddTextObject("Patient Test Report", 6000, 400)

        ' Add fields to details section
        ' Note that the Sections collection can be accessed via
        ' number or string index
        repdoc.Sections("D").AddFieldObject("{ado.sname}", 750, 5)
        repdoc.Sections("D").AddFieldObject("{ado.fname}", 3150, 5)
        repdoc.Sections("D").AddFieldObject("{ado.dob}", 5500, 5)
        repdoc.Sections("D").AddFieldObject("{ado.adr1}", 8850, 5)

        CRViewer91.ReportSource = repdoc
        CRViewer91.ViewReport()

    End Sub



Reply With Quote
  #3 (permalink)  
Old November 16th, 2006, 04:41 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
Even I'm working on a requirement that is something very much similar. I didnt understand what you meant by "You need a lisence to create Custom reports at runtime"..?

Can you give me more details as to ..what reference to add, namespaces to be imported..

Thanking you in anticipation..

Regards,
Sarith

Reply With Quote
  #4 (permalink)  
Old February 12th, 2008, 09:29 AM
Registered User
 
Join Date: Nov 2006
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What I meant was you CANNOT do this with the free version of Crystal you get with VS2005. In order to dynamically set-up a data set you must purchase a developer license from business objects which costs a lot. Then for every user you then deploy the application to another license for each of them is required!

To do this kind of thing use Microsoft RDLC and report viewer that come with VS 2005. Hope this helps anybody in the same situation!!

Reply With Quote
  #5 (permalink)  
Old March 21st, 2013, 10:01 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Wink VB.NET - creating a CR report at run time

I have good experience in create report with crystal report in design runtime
you can ask me personally in riyadia82@gmail.com or contact on +6285743784380 (Indonesia)
I could help you free
This code is work well in my application

Imports System.Data

Imports CRAXDRT
Imports CRVIEWERLib

Imports ADODB

Public Class RptPrive
Dim DbPrive As New ADODB.Connection
Dim CmdPrive As New ADODB.Command

Dim app As New CRAXDRT.Application
Dim Xreport As CRAXDRT.Report

Private Sub DataSource()

DbPrive.Open("DRIVER={SQL SERVER};SERVER=SCIENTIST; " _
& "DATABASE=Db_Kas; UID=SA; PWD=;")

CmdPrive = New ADODB.Command()
CmdPrive.ActiveConnection = DbPrive
CmdPrive.CommandText = "SELECT * FROM TB_PRIVE ORDER BY KD_PRIVE ASC "

CmdPrive.CommandType = CommandTypeEnum.adCmdText
Xreport.Database.AddADOCommand(DbPrive, CmdPrive)

End Sub
Private Sub RptPrive_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

app = New CRAXDRT.Application
Xreport = app.NewReport

DataSource()

Xreport.Sections("D").AddFieldObject("{ADO.KD_PRIV E}", 750, 5)
Xreport.Sections("D").AddFieldObject("{ado.NAMA}", 3150, 5)
Xreport.Sections("D").AddFieldObject("{ado.ALAMAT} ", 5500, 5)
Xreport.Sections("D").AddFieldObject("{ado.NO_TELE PHON}", 8850, 5)

CrvPrive.Top = 0
CrvPrive.Height = Me.Height
CrvPrive.Width = Me.Width

Xreport.PaperSize = CRPaperSize.crPaperLegal


CrvPrive.ReportSource = Xreport

CrvPrive.ViewReport()
CrvPrive.Zoom(100)


End Sub

Last edited by ARiyadi; March 21st, 2013 at 10:08 AM..
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
Recipe to change CR query at run time. dbron Crystal Reports 4 June 24th, 2009 03:07 AM
Control resize and positioning at run time. VB.Net TechNik .NET Framework 2.0 5 November 14th, 2008 09:00 AM
How to change CR 11 database name at run time, ASP enghok Classic ASP Professional 3 September 26th, 2007 03:28 AM
change database location on CR 10 at run time blu3_x30n Pro VB 6 0 March 30th, 2006 01:25 PM
Change picture at run-time with CR for .NET? NTurnbullJr Crystal Reports 2 March 31st, 2005 05:29 AM



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


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