473,394 Members | 1,759 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

push data into crystal report

Hi,

I want to push data from a winform into a crystal report document but .
I found everithing in the FAQ 'crystal report' and other posts in forums but it doesn't work.
Here is my code.(it doesn't work).

***************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim crpt As New CrystalReport2
Dim strSQL As String = "SELECT * from products WHERE SupplierId = 1"
Dim ds As New DataSet
Dim conn As SqlConnection = New SqlConnection("server=turing;database=northwind;in tegrated security=true;")
Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, conn)

conn.Open()
da.Fill(ds, "products")
conn.Close()

crpt.SetDataSource(ds)
CrystalReportViewer1.ReportSource = crpt

End Sub
***************
If someone could help me.
Thank you.

Nov 20 '05 #1
1 2335
#region GetCrystalPushReport
private ReportDocument GetCrystalPushReport(ReportDescriptor _Descriptor)
{
if(_Descriptor.Describes == null) {
throw new System.ArgumentNullException("Descriptor.Describes ") ;
}
Report Report = _Descriptor.Describes ;
ReportDocument Return = new ReportDocument() ;
DbDataProvider data = new DbDataProvider() ;
string filename = data.GetReportFile(Report) ;
Return.Load(filename) ;

//got the report
DataSet bar =
CrystalDataBuilder.GetInstance().GetReportData(_De scriptor);
SetReportDataSource(Return, bar);
return Return;
}
is what I use ... the Descriptor has metadata information associated with it
that describes the data to pull ...

private void SetReportDataSource(ReportDocument _Report, DataSet _ds) {
_Report.SetDataSource(_ds) ;

for (int i = 0; i < _Report.ReportDefinition.ReportObjects.Count; i++) {
ReportObject CurrentObject = _Report.ReportDefinition.ReportObjects[i];

if(CurrentObject.Kind ==
CrystalDecisions.Shared.ReportObjectKind.Subreport Object) {
ReportDocument SubReport =
_Report.OpenSubreport(((SubreportObject)CurrentObj ect).SubreportName);
SetReportDataSource(SubReport, _ds) ;
}
}
}

sets the data source for the report and all subreports ...
"laumon" <la****@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
Hi,

I want to push data from a winform into a crystal report document but .
I found everithing in the FAQ 'crystal report' and other posts in forums but it doesn't work. Here is my code.(it doesn't work).

***************
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim crpt As New CrystalReport2
Dim strSQL As String = "SELECT * from products WHERE SupplierId = 1" Dim ds As New DataSet
Dim conn As SqlConnection = New SqlConnection("server=turing;database=northwind;in tegrated security=true;") Dim da As SqlDataAdapter = New SqlDataAdapter(strSQL, conn)

conn.Open()
da.Fill(ds, "products")
conn.Close()

crpt.SetDataSource(ds)
CrystalReportViewer1.ReportSource = crpt

End Sub
***************
If someone could help me.
Thank you.

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Robert Schuldenfrei | last post by:
Dear NG, I have done all I can do with Crystal Reports (CR) using the "pull" mode. I now need to generate data in my application, load a DataSet with that data, and "push" this on to a CR...
0
by: Lisa | last post by:
I am trying to create a Crystal Report for my ASP.NET application that will allow the user to select a specific group of client addresses to create mailing labels. Since this is an ASP.NET...
3
by: Karine Proot | last post by:
Hello, I created two reports : - OleDbReport.rpt, with an OLE DB (ADO) data source (took only table 'stores' from database 'pubs') - DataSetReport.rpt, with an ADO.NET DataSet as a data source...
1
by: mike11d11 | last post by:
For some reason I'm getting no data populating in my crystal report. I built my crystal report off my dataset in my project, and I fill the dataset when opening the main form, and count the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.