Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi! I'm working on VB.Net and this is the first time that I'm using crystal

reports. I'm not able to find any basic documentation regarding how do we go

about it. I have created & designed a report. I'm using MS Access and by

connecting to it have got the list of tables in the database fields

explorer. Now after that, I've added a CRV on my form and set the datasource

to a dataset that I've created programatically. When I view the report, it

does not even load the design elements in my report. It's fully blank. The

dataset is not blank. Can anybody please help me with this. If there are any

tutorials, sample codes on this and if somebody could point me to it, it

would be really helpful. Thanx!

  • Leaders
Posted

I've got Enterprise Architect edition and it came with an example for both WinForm and WebForms. Check here or the equivelent location on your box:

C:\Program Files\Microsoft Visual Studio .NET\Crystal Reports\Samples\Code\WinForms\VB

--tim
  • 4 months later...
Posted

sorry for digging up an old thread.

 

whizkid123, i'm facing the same situation as you. have you managed to solve the problem?

 

i've looked at the example but it's a tad simple..

 

-ashrobo

Posted

after you have created your dataset pass it to the form that will display your report and set the forms private dataset variable to the dataset being passed to the form

 


Private m_dsReportSource As System.Data.DataSet


  
Public Sub New(ByVal dsReportSource As System.Data.DataSet)
       MyBase.New()


       'This call is required by the Windows Form Designer.
       InitializeComponent()


       'Add any initialization after the InitializeComponent() call


        ' set the forms dataset variable to passed dataset


       m_dsReportSource = dsReportSource


   End Sub

 

then setup your report as follows....

 


Private Sub CrystalReportViewer1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles CrystalReportViewer1.Load

        myReport = New repWhatEver()


        myReport.SetDataSource(m_dsReportSource)


        Me.CrystalReportViewer1.ReportSource = myReport


End Sub

My website
Posted
Maybe not the most elegant way but I create a temp dataadapter and dataset on the form in design mode to make all the required fields accessible. Then when the report is as I want it I just assign the dynamic dataset to the report at runtime and all works a treat
My website
Posted

i tried it but it didn't work as i thought it would.. when the crystal report viewer was loaded, it loads the crystal report which in turn asked me about the logon details. any clues?

 

-ashrobo

Posted (edited)

This example will show you how you can dynamicaly load data in to a report and view in a CRV

 

Imports CrystalDecisions.CrystalReports
Imports System.Data
Imports System.Data.SqlClient
Public Class frmDeliveryReport
   Inherits System.Windows.Forms.Form
   Public myRpt As New rptOrderDelivery()
   Public intDeliveryId As Integer

<HERE FORM DESIGNER CODE>

   Private Sub frmDeliveryReport_Load() Handles MyBase.Load
       Dim myAdapter As SqlDataAdapter = New SqlDataAdapter("SELECT Some Day Where OrderDelivery.DeliveryID = " & intDeliveryId, mySQL)
       Dim myDS As DataSet = New DataSet()
       myAdapter.Fill(myDS)
       myRpt.SetDataSource(myDS.Tables(0))
       crvDEL.ReportSource = myRpt
       crvDEL.Zoom(2)
   End Sub

 

 

Remeber these Steps

 

1- Design a Crystal Report from ADO.NET generated XML file. you can create it from adding a new XML Schema File or asking and Adapter to generate a data set. this file is nothing just a sequence of colums which your Query will return.

 

2- Then on the Report Form you first need to instentiate that report file ang generate some data set from some query

 

3- then From that generated data set , set the datasource property of Report to that data set. so the report loads data in it

 

4- and at the end you need to set to CRV report source property to that generated report.

Edited by Madz

The one and only

Dr. Madz

eee-m@il

Posted
Madz, haven't tried your approach, but just looking at the steps required it seems to be a lot of effort whereby simply having a temp dataset & dataadapter in design mode would suffice.
My website
Posted

a million thanks to you, madz.. :) finally, i'm able to create a report for 1 record. now the problem is the "details" which in my case, is invoice details, cannot be displayed. i dragged the field "itemno" down onto the report and when i run it, i get "query engine error".

 

- ashrobo

Posted
Madz, haven't tried your approach, but just looking at the steps required it seems to be a lot of effort whereby simply having a temp dataset & dataadapter in design mode would suffice.

 

in fact, i only managed to get it going after following Madz's steps..

 

hog, i thought Madz's steps were similar to yours. he has a XML schema file while you have a dataset and dataadapter.

 

thanks guys/gals,

- ashrobo

Posted

Dear There is nothing difficult with it. Just Do these Steps

 

1- Generate an XML file this is required for Crytal Report if you want to use ADO.NET with Report. its much easier to generate it Just you need to add an XML Schema File to your Solution. then from Server Explorer Expand the SQL Server List and then Drag the Desired Table to the File.

 

2- Then FRom CR Report Designer choose ADO.NET it will ask you to open some XML File then path to that file and choose the columns which you want to show on table.

 

3- then design the Report with code above. and Query the Table which you want to show on report. and fill the report with that.

 

the above example it from a real project this shows the Delivery Report on a paid order. Which shows the desired delivery report and get it by report id.

 

Here an other example which shows the sales record on report

it is much easier. and same as the old one

 

   Public rptDel As New rptPaymentsReport()
   Private Sub frmDealerReport_Load() Handles MyBase.Load
       On Error Resume Next
       Dim myAdapter As SqlDataAdapter = New SqlDataAdapter(strQuery, mySQL)
       Dim myDs As DataSet = New DataSet()
       myAdapter.Fill(myDs)
       rptDel.SetDataSource(myDs.Tables(0))
       crvDealer.ReportSource = rptDel
       crvDealer.Zoom(2)
       crvDealer.RefreshReport()
   End Sub

The one and only

Dr. Madz

eee-m@il

Posted

urmm, i am able to display the invoice headers based on the steps that you've listed out, Madz..

 

it's the Invoice Details that are not coming out now.. fields such as "Invoice.InvoiceNo", "Invoice.InvoiceDate", etc are fine. however, if i add the field "InvOrders.ItemNo", the error will occur but if i add the field "InvOrders.InvoiceNo", no error.

 

:confused:

-ashrobo

Posted
I suppose it's each to his own. I've done loads of reports using my method with no problem. Just seems like there is more steps in your method. Anyway whichever way it's done they both work so that's all that matters :-)
My website
Posted

OK madz, I'm always up for trying something new....

 

I have added a blank xml file to my project, but if I try to drag a table from my access connection it does not allow me to do so.

My website
Posted
OK madz, I'm always up for trying something new....

 

I have added a blank xml file to my project, but if I try to drag a table from my access connection it does not allow me to do so.

really? i could just drag the table over without any errors..

Posted
I dont thing so, there might be some thing missing coz it is so much easy just drag the table to designer and it will add a table.

The one and only

Dr. Madz

eee-m@il

Posted

No...it won't have it?

 

I add a blank xml file to my solution

I expand the tables in solution explorer

I click and drag the required table, but get the black circle with the line through it signifying not allowed, which doesn't let me do jack with the table??

My website

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...