Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: VS 2005 .NET Crystal Reports Beginner Post Reply Post New Topic
Author Message
cruser1234
Newbie
Newbie


Joined: 19 Jan 2007
Online Status: Offline
Posts: 1
Quote cruser1234 Replybullet Topic: VS 2005 .NET Crystal Reports Beginner
    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.
 
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
david.slash
Newbie
Newbie


Joined: 31 Mar 2008
Location: United Kingdom
Online Status: Offline
Posts: 1
Quote david.slash Replybullet Posted: 31 Mar 2008 at 3:42am
If you are new in Crystal report just try this link
 
 
best regards.
 
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.