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.Connection = conn
daReport.SelectCommand.CommandText = "SELECT * FROM CLNMAS
WHERE City = 'Miami'"
daReport.Fill(dsReport, "tReportData")
rpt.SetDatabaseLogon("UserName", "Password",
"ServerName", "DbName")
rpt.SetDataSource(dsReport.Tables("tReportData"))
Dim frm As New CrystalViewer(aryHeadings, aryFields, rpt)
frm.crvMain.ReportSource = rpt
frm.MdiParent = Me.MdiParent
frm.Show()
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.Connection = conn
daReport.SelectCommand.CommandText = "SELECT * FROM CLNMAS
WHERE City = 'Miami'"
daReport.Fill(dsReport, "tReportData")
rpt.SetDatabaseLogon("UserName", "Password",
"ServerName", "DbName")
rpt.SetDataSource(dsReport.Tables("tReportData"))
Dim frm As New CrystalViewer(aryHeadings, aryFields, rpt)
frm.crvMain.ReportSource = rpt
frm.MdiParent = Me.MdiParent
frm.Show()