Hi all,
Firstly: I am using crystal version that comes with visual studio .net 2003, SQL Server and ADO.Net
I am trying to create a report that takes information from more than one table: for example, if you have a customer table and an orders table, based on a sql join query, i want the report to display all orders for a particular customer.
Now, i know my main code is not the problem because if i try to connect to just one table, it works. As soon as i try to add another table, link it in the dataset and write a join query, nothing comes up.
Here is my main code:
**********************
Public Class WebForm1
Inherits System.Web.UI.Page
''CR Variable (the actual physical report file- in this case CrystalReport1.rpt- don't specify extension
Dim crReportDocument As CrystalReport4
''ADO.NET Variables
Dim adoOleDbConnection As OleDbConnection
Dim adoOleDbDataAdapter As OleDbDataAdapter
Protected WithEvents CrystalReportViewer1 As CrystalDecisions.Web.CrystalReportViewer
Dim dataSet As Dataset7
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
''Build a connection string
Dim connectionString As String = ""
connectionString = "Provider=SQLOLEDB;"
connectionString += "Server=WEBMASTER;Database=Pubs;"
connectionString += "User ID=sa;Password=thames"
''Create and open a connection using the connection string
adoOleDbConnection = New OleDbConnection(connectionString)
''Build a SQL statement to query the datasource
Dim sqlString As String = ""
sqlString = "SELECT TOP 5 dbo.pub_info.pr_info, dbo.publishers.pub_name, dbo.publishers.city, dbo.publishers.state, dbo.publishers.country FROM dbo.pub_info INNER JOIN dbo.publishers ON dbo.pub_info.pub_id = dbo.publishers.pub_id"
''Retrieve the data using the SQL statement and existing connection
adoOleDbDataAdapter = New OleDbDataAdapter(sqlString, adoOleDbConnection)
''Create a instance of a Dataset
dataSet = New Dataset7
''Fill the dataset with the data retrieved. The name of the table
''in the dataset must be the same as the table name in the report.
adoOleDbDataAdapter.Fill(dataSet, "Pubs")
''Create an instance of the strongly-typed report object
crReportDocument = New CrystalReport4
''Pass the populated dataset to the report
crReportDocument.SetDataSource(dataSet)
''Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument
End Sub
End Class
Any help Much appreciated!