Print Page | Close Window

VS 2005 .NET Crystal Reports Beginner

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=137
Printed Date: 18 Apr 2024 at 8:51pm


Topic: VS 2005 .NET Crystal Reports Beginner
Posted By: cruser1234
Subject: VS 2005 .NET Crystal Reports Beginner
Date Posted: 19 Jan 2007 at 9:00am
 
I'm just starting out with crystal reports, it looks really cool but I'm having difficulty. As my first project I just want to bind a simple table to a report and view it. Here is my code:
 

Dim myCrystalReport As New CrystalReport1

Dim con As New SqlClient.SqlConnection

Dim com As New SqlClient.SqlCommand

Dim sqlapa As New SqlClient.SqlDataAdapter

Dim dt As New DataTable

con.ConnectionString = "..."

con.Open()

com.Connection = con

com.CommandType = CommandType.Text

com.CommandText = "select webuserid, username from twebuser"

sqlapa.SelectCommand = com

sqlapa.Fill(dt)

MessageBox.Show(dt.Rows.Count.ToString)

myCrystalReportViewer1.DisplayGroupTree = False

myCrystalReportViewer1.Zoom(100)

myCrystalReport.SetDataSource(dt)

myCrystalReportViewer1.ReportSource = myCrystalReport

con.Close()

 

The error is occuring on this line:
myCrystalReport.SetDataSource(dt)
 
The error states "The Report has no tables".
 
I get 24 results on the messagebox so I know the data is being properly read into the datatable. Please help.
 



Replies:
Posted By: BrianBischof
Date Posted: 19 Jan 2007 at 10:17am
I think you might be doing things out of order. How did you build your report? You have to create the report based on the XSD file (where all your table definitions are stored) and then you can run this code.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: david.slash
Date Posted: 31 Mar 2008 at 3:42am
If you are new in Crystal report just try this link
 
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_step_by_step.htm - http://vb.net-informations.com/crystal-report/vb.net_crystal_report_step_by_step.htm
 
best regards.
 



Print Page | Close Window