Add table to Crystal report in VB.NET

G

GatorBait

Hi all,


I have a VB.NET application that uses SQL server and Crystal.
Basically what I am trying to do is have a report in which the user can

select which fields will appear on the report. I have everything set
up correctly and working in a small sample project. I attempted to
incorporate it into my main project but I'm running into a problem
because the report has no table attached to it because the table I use
will depend on what fields the user selects to view on the report. My
question is how can I add a table to the report within the code?


Here is some code I am using to display the report. I am getting an
error saying "The report has no tables." I'm trying to figure out how
I can add the table at runtime...


Dim conn As New SqlConnection()
Dim daReport As New SqlDataAdapter()
Dim dsReport = New DataSet()
Dim rpt As New GeneralReport_P()
Dim aryHeadings() As String
Dim aryFields() As String


conn = GetMainConnSQL("UserName", "Password",
"ServerName")
daReport.SelectCommand = New SqlCommand()
daReport.SelectCommand.Connect­­ion = conn
daReport.SelectCommand.Command­­Text = "SELECT * FROM CLNMAS
WHERE City = 'Miami'"
daReport.Fill(dsReport, "tReportData")


rpt.SetDatabaseLogon("UserName­", "Password",
"ServerName", "DbName")
rpt.SetDataSource(dsReport.Tab­­les("tReportData"))


Dim frm As New CrystalViewer(aryHeadings, aryFields, rpt)
frm.crvMain.ReportSource = rpt
frm.MdiParent = Me.MdiParent
frm.Show()
 
T

Thomas Wenning

Hi all,


I have a VB.NET application that uses SQL server and Crystal.
Basically what I am trying to do is have a report in which the user can

select which fields will appear on the report. I have everything set
up correctly and working in a small sample project. I attempted to
incorporate it into my main project but I'm running into a problem
because the report has no table attached to it because the table I use
will depend on what fields the user selects to view on the report. My
question is how can I add a table to the report within the code?


Here is some code I am using to display the report. I am getting an
error saying "The report has no tables." I'm trying to figure out how
I can add the table at runtime...


Dim conn As New SqlConnection()
Dim daReport As New SqlDataAdapter()
Dim dsReport = New DataSet()
Dim rpt As New GeneralReport_P()
Dim aryHeadings() As String
Dim aryFields() As String


conn = GetMainConnSQL("UserName", "Password",
"ServerName")
daReport.SelectCommand = New SqlCommand()
daReport.SelectCommand.Connect­­ion = conn
daReport.SelectCommand.Command­­Text = "SELECT * FROM CLNMAS
WHERE City = 'Miami'"
daReport.Fill(dsReport, "tReportData")


rpt.SetDatabaseLogon("UserName­", "Password",
"ServerName", "DbName")
rpt.SetDataSource(dsReport.Tab­­les("tReportData"))


Dim frm As New CrystalViewer(aryHeadings, aryFields, rpt)
frm.crvMain.ReportSource = rpt
frm.MdiParent = Me.MdiParent
frm.Show()

Hi Gator,

use a dataset.
http://support.businessobjects.com/...Papers/rtm_reportingoffadonetdatasets.pdf.asp
http://support.businessobjects.com/library/kbase/articles/c2010929.asp
http://support.businessobjects.com/communityCS/TechnicalPapers/crnet_adonet.pdf
http://support.businessobjects.com/communityCS/TechnicalPapers/rtm_reportingoffadonetdatasets.pdf

Greeting

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top