Hi, could you direct me to any examples, where I could see how passing my sql string onto a dataset, afterwhich displaying my data within my dataset. I followed an example from one of the books "Crystal Reports for Visual Studio .NET" by wrox. But I do not
seem to get the desired results, I just get a blank page, although my tables do contains data.
Dim ds As New Report()
Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim comm As String = "Select * from vew_leave_report"
Dim adpt As New SqlDataAdapter(comm, conn)
adpt.Fill(ds)
Response.Write(ds.Tables(0).Rows.Count)
Dim myReport As New MyeLeaveReport()
myReport.SetDataSource(ds)
CrystalReportViewer2.ReportSource = myReport
Report() = the name of my .xsd file MyeLeaveReport() = name of my .rpt file CrystalReportViewer2 = crystal report component And finally, Response.Write(ds.Tables(0).Rows.Count)
returns me 0
Your code is perfect. The problem is that no data is going into it as shown when you call Response.Write(ds.Tables(0).Rows.Count). Do you know how to fill a dataset? If not have a look at some of the examples on MSDN. I would have a look at the following places
for more examples on crystal: http://www.businessobjects.com/products/dev_zone/default.asp http://www.aspalliance.com/crystal http://dotnetjunkies.com/WebLog/richard.dudley/category/1087.aspx And I have that Wrox book and it is straight out terrible when it
comes to specific, I bought the book at www.crystalreportsbook.com and was able to go from a beginner to doing things like changing sorting and grouping at runtime. Hope this helps Ryan
Yeah but you have to have the select command of the dataadapter properly configured to fill the dataset. Did you create the adapter and dataset in the designer or are you just declaring them. You need to get it so the rows are more than 0. Ryan
Alright, I got it to work, it should be Dim ds As New DataSet("vew_leave_report") Right now, nothing displays on my report page. Dim myReport As New MyeLeaveReport() myReport.SetDataSource(ds) CrystalReportViewer2.ReportSource = myReport My .rpt file is empty
btw.
When I try dragging a field onto my .rpt file, I get this: Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: CrystalDecisions.CrystalReports.Engine.DataSourceException: Query Engine Error: 'C:\WINNT\TEMP\temp_09632bc0-3f05-4e74-9e58-b412c79623d2.rpt'
I would start again: 1. In the designer create a dataadapter, then create a dataset from this dataadapter. 2. Create a new report and set the dataset as the datasource. 3. In the code fill the dataset (make sure there are rows being filled) 4. Then bind the
report to the dataset Ryan
RyanSmith
Participant
1944 Points
374 Posts
Re: Displaying in Crystal Reports
Jan 27, 2005 10:35 PM|LINK
eXtension
Contributor
2015 Points
747 Posts
Re: Displaying in Crystal Reports
Jan 28, 2005 09:28 AM|LINK
Dim ds As New Report() Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim comm As String = "Select * from vew_leave_report" Dim adpt As New SqlDataAdapter(comm, conn) adpt.Fill(ds) Response.Write(ds.Tables(0).Rows.Count) Dim myReport As New MyeLeaveReport() myReport.SetDataSource(ds) CrystalReportViewer2.ReportSource = myReportReport() = the name of my .xsd file MyeLeaveReport() = name of my .rpt file CrystalReportViewer2 = crystal report component And finally, Response.Write(ds.Tables(0).Rows.Count) returns me 0RyanSmith
Participant
1944 Points
374 Posts
Re: Displaying in Crystal Reports
Jan 28, 2005 10:18 PM|LINK
eXtension
Contributor
2015 Points
747 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 12:24 AM|LINK
RyanSmith
Participant
1944 Points
374 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 12:35 AM|LINK
eXtension
Contributor
2015 Points
747 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 12:49 AM|LINK
eXtension
Contributor
2015 Points
747 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 01:44 AM|LINK
RyanSmith
Participant
1944 Points
374 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 02:37 AM|LINK
eXtension
Contributor
2015 Points
747 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 03:50 AM|LINK
RyanSmith
Participant
1944 Points
374 Posts
Re: Displaying in Crystal Reports
Jan 31, 2005 05:50 AM|LINK