PC Review


Reply
Thread Tools Rate Thread

Can't get the Crystal Reports Viewer to bind with my dataset.

 
 
Bob Clegg
Guest
Posts: n/a
 
      14th Jul 2004
I am in the same boat as Moondog on the 2nd July.
I have a report designed against a dataset.
Proved the datasset is OK by dropping a datagrid onto the form and it binds
OK to the data.
But the report is empty (except for headers). My method is similar to
Moondog except the dataset is based on a SProc.
The dataset is instantiated in FormA, passed to a DataHandling class which
fills it. by executing the SProc
it is then passed to the report form in the constructor.
The constructor then passes it down to a subroutine 'loadreport' which
attempts to bind it to the report viewer
Code is :
Private Sub loadreport(ByRef dsevents As dsReportEvent)

' Called by new(ByRef dsevents As dsReportEvent)

Me.dg1.DataSource = dsevents

Me.dg1.DataMember = "Table"'Datagrid sanity check

mRpt = New rptEventReport 'report class underlying report based on dsEvents

mRpt.SetDataSource(dsevents)

Me.crvMain.ReportSource = mRpt 'setting the viewer

End Sub

Any help would be appreciated.
Thanks
Bob


 
Reply With Quote
 
 
 
 
Bob Clegg
Guest
Posts: n/a
 
      14th Jul 2004
Hi Brian,
Thanks for your reply.
No Joy.
I coded:
Private Sub loadreport(ByRef dsevents As dsReportEvent)

Dim crReportDocument As rptEventReport

crReportDocument = New rptEventReport

Dim ds As DataSet

ds = dsevents 'NOTE here I am still pointing to my original dataset.

Dim dstest As String = ds.GetXml 'dstest shows well formed doc with data



crReportDocument.SetDataSource(ds)




Me.crvMain.ReportSource = crReportDocument

Me.crvMain.Visible = True

End Sub

The test string showed an xml doc with data.

I do have dates in the data.
I'll alter the sproc / dataset / report to give a one integer field rowset
and see if that helps.
If it does then I'll build up from there.
If it is data then this control is not much use.
Is there any 3rd party viewer around that anybody knows of?
Thanks
Bob

"BrianDH" <(E-Mail Removed)> wrote in message
news:7EEE2BF0-DC5F-493C-9983-(E-Mail Removed)...
> Try this.
> Dim crReportDocument As rptEventReport
> crReportDocument = New rptEventReport
> Dim dsevents As DataSet = "get your dataset values"
> Dim strTests As String = dsevents.GetXml ' break point here view/test your

DS XML
> crReportDocument.SetDataSource(dsevents)
> CrystalReportViewer1.ReportSource = crReportDocument
> CrystalReportViewer1.Visible = True
>
> If this does not work.
> Question: Are you using any formulas? running totals? also date time

fields can give you fits with CR.
>
> hope that helps.
>
> B
>
>
> "Bob Clegg" wrote:
>
> > I am in the same boat as Moondog on the 2nd July.
> > I have a report designed against a dataset.
> > Proved the datasset is OK by dropping a datagrid onto the form and it

binds
> > OK to the data.
> > But the report is empty (except for headers). My method is similar to
> > Moondog except the dataset is based on a SProc.
> > The dataset is instantiated in FormA, passed to a DataHandling class

which
> > fills it. by executing the SProc
> > it is then passed to the report form in the constructor.
> > The constructor then passes it down to a subroutine 'loadreport' which
> > attempts to bind it to the report viewer
> > Code is :
> > Private Sub loadreport(ByRef dsevents As dsReportEvent)
> >
> > ' Called by new(ByRef dsevents As dsReportEvent)
> >
> > Me.dg1.DataSource = dsevents
> >
> > Me.dg1.DataMember = "Table"'Datagrid sanity check
> >
> > mRpt = New rptEventReport 'report class underlying report based on

dsEvents
> >
> > mRpt.SetDataSource(dsevents)
> >
> > Me.crvMain.ReportSource = mRpt 'setting the viewer
> >
> > End Sub
> >
> > Any help would be appreciated.
> > Thanks
> > Bob
> >
> >
> >



 
Reply With Quote
 
bclegg
Guest
Posts: n/a
 
      15th Jul 2004
OK Problem Solved.
You have to use the overloaded version of the dataadapter fill command.
ie.
Dim cmdConn As New SqlClient.SqlCommand("proc_GetEventReportData",
NewSqlClient.SqlConnection(strConnection))

cmdConn.Parameters.Add(New SqlClient.SqlParameter("@strIDList",
SqlDbType.NVarChar))

cmdConn.Parameters("@strIDList").Value = mstrUnitList
cmdConn.CommandType = CommandType.StoredProcedure
Dim da As New SqlClient.SqlDataAdapter(cmdConn)
Dim ds As New dsReportEvent
da.Fill(ds, "ReportEvent")
Dim rd As New rptEventReport
rd.SetDataSource(ds)

The big 'break through' was realising that "ReportEvent" was needed.
The documentation alludes to this but leaves the impression that is it
mainly for table verification.
This HAD to be the name of the Element that was inside my typed dateset.
My element was handrolled and not actually a table so it seemed
reasonable to use the default constructor and accept the generated table
name "Table".
Alas no.
Moondog, if your out there, good luck.
regards
Bob



Bob Clegg wrote:
> Hi Brian,
> Thanks for your reply.
> No Joy.
> I coded:
> Private Sub loadreport(ByRef dsevents As dsReportEvent)
>
> Dim crReportDocument As rptEventReport
>
> crReportDocument = New rptEventReport
>
> Dim ds As DataSet
>
> ds = dsevents 'NOTE here I am still pointing to my original dataset.
>
> Dim dstest As String = ds.GetXml 'dstest shows well formed doc with data
>
>
>
> crReportDocument.SetDataSource(ds)
>
>
>
>
> Me.crvMain.ReportSource = crReportDocument
>
> Me.crvMain.Visible = True
>
> End Sub
>
> The test string showed an xml doc with data.
>
> I do have dates in the data.
> I'll alter the sproc / dataset / report to give a one integer field rowset
> and see if that helps.
> If it does then I'll build up from there.
> If it is data then this control is not much use.
> Is there any 3rd party viewer around that anybody knows of?
> Thanks
> Bob
>
> "BrianDH" <(E-Mail Removed)> wrote in message
> news:7EEE2BF0-DC5F-493C-9983-(E-Mail Removed)...
>
>>Try this.
>>Dim crReportDocument As rptEventReport
>>crReportDocument = New rptEventReport
>>Dim dsevents As DataSet = "get your dataset values"
>>Dim strTests As String = dsevents.GetXml ' break point here view/test your

>
> DS XML
>
>>crReportDocument.SetDataSource(dsevents)
>>CrystalReportViewer1.ReportSource = crReportDocument
>>CrystalReportViewer1.Visible = True
>>
>>If this does not work.
>>Question: Are you using any formulas? running totals? also date time

>
> fields can give you fits with CR.
>
>>hope that helps.
>>
>>B
>>
>>
>>"Bob Clegg" wrote:
>>
>>
>>>I am in the same boat as Moondog on the 2nd July.
>>>I have a report designed against a dataset.
>>>Proved the datasset is OK by dropping a datagrid onto the form and it

>
> binds
>
>>>OK to the data.
>>>But the report is empty (except for headers). My method is similar to
>>>Moondog except the dataset is based on a SProc.
>>>The dataset is instantiated in FormA, passed to a DataHandling class

>
> which
>
>>>fills it. by executing the SProc
>>>it is then passed to the report form in the constructor.
>>>The constructor then passes it down to a subroutine 'loadreport' which
>>>attempts to bind it to the report viewer
>>>Code is :
>>>Private Sub loadreport(ByRef dsevents As dsReportEvent)
>>>
>>> ' Called by new(ByRef dsevents As dsReportEvent)
>>>
>>>Me.dg1.DataSource = dsevents
>>>
>>>Me.dg1.DataMember = "Table"'Datagrid sanity check
>>>
>>>mRpt = New rptEventReport 'report class underlying report based on

>
> dsEvents
>
>>>mRpt.SetDataSource(dsevents)
>>>
>>>Me.crvMain.ReportSource = mRpt 'setting the viewer
>>>
>>>End Sub
>>>
>>>Any help would be appreciated.
>>>Thanks
>>>Bob
>>>
>>>
>>>

>
>
>



--
Please take out the garbage before using reply address.

 
Reply With Quote
 
Moondog
Guest
Posts: n/a
 
      22nd Jul 2004
Hmmm, I think I did try that method bclegg, but still had no luck.

But I did manage to get it working. Here's how:

In my code after I get my dataset I run this line once:

myDataSet.WriteXmlSchema("C:\MyReport.xsd")

This creates a file called MyReport.xsd that contains the description
of my data. Next I create a new Crystal Report using MyReport.xsd as
my ADO.NET (XML) source. Once the new report is created you can
delete MyReport.xsd, and also delete the line of code that created the
xsd file. The new report created will then accept my dataset during
runtime.

Dominic Isaia (Moondog)
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: I want to bind a runtime-generated dataset to a crystal report.HELP!!! tomb Microsoft VB .NET 0 27th Sep 2005 03:29 PM
Crystal Reports Viewer Aaron Smith Microsoft VB .NET 3 4th Dec 2004 10:36 AM
Can't get the Crystal Reports Viewer to bind with my dataset. Moondog Microsoft VB .NET 0 1st Jul 2004 10:35 PM
Crystal Reports Viewer Dmitry Karneyev Microsoft C# .NET 2 19th Mar 2004 10:27 AM
Anyone used the Crystal Reports Viewer in .Net? Ed Bangle Microsoft ASP .NET 0 23rd Nov 2003 03:03 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:58 PM.