Click to See Complete Forum and Search --> : VB2005 No data in report
bodylojohn
Nov 25th, 2006, 06:06 AM
Hello,
I just created a crystal report with the 'CrytalreportViewer'. I used the ADO.NET datasets.
A report is shown but there is no data in it.
What did I do wrong???
I searched the forums here but I havent found my solution yet.
I hope you guys can help me....
shakti5385
Nov 25th, 2006, 06:32 AM
Have you connect the report with the database. Read the CR In VB.Net at my signature for more detail.
bodylojohn
Nov 25th, 2006, 06:40 AM
Hello,
I have tried your code:
Imports System.Data
Imports System.Data.OleDb
Public Class Form1
Dim myConnection As New OleDb.OleDbConnection
Public Sub FillDataset()
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\SOSOL\Klanten\Mutlu\Projecten\Textiel\BackUp\BU20061125\Data\Textielbedrijf2000.mdb"
'Set the table adapters' connection
'Open connection
myConnection.Open()
'Close the connection to the database
'myConnection.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call FillDataset()
Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
CrystalReportViewer1.ActiveViewIndex = 0
CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
CrystalReportViewer1.Name = "CrystalReportViewer1"
Dim QueryString As String = "select * from tblLand" 'Your Query here
'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
'Connection.Open()
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
Dim DataSet As DataSet = New DataSet() 'DataSet
Adapter.Fill(DataSet)
Dim DataTable As DataTable = New DataTable 'DataTable
DataTable = DataSet.Tables(0) 'filling the datatable here
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
Report.SetDataSource(DataTable)
CrystalReportViewer1.ReportSource = Report
End Sub
End Class
But it doesn't work.
The report openes inside the crystalreportviewer but there is no data.
Just the columnheaders.
shakti5385
Nov 25th, 2006, 08:05 AM
Check the datatable trace the code if you are getting the data in the datatable then the record will appear in the Cr also.
bodylojohn
Nov 25th, 2006, 09:08 AM
The dataTable has data in it.
I also see the 2 columnheaders in the crystalreportviewer.
But I just dont see any data...
bodylojohn
Nov 25th, 2006, 10:19 AM
When I use 'New Connection' when I make a crystal Report It works and I get data Purely by using the wizzard.
But here is my problem.
What if the path of my ms access database changes??????
How can I solve this.
Here is my situation:
I have created a CR by project --> Add new item.
Then I choose 'new connection' and selected the ms access database.
Then I added an CrystalReportViewer to my form and let it open the CR that I just created.
This works.
But what if the database path changes???
bodylojohn
Nov 30th, 2006, 07:10 AM
Does anybody have a solution for my problem?
shakti5385
Nov 30th, 2006, 07:21 AM
But what if the database path changes???
No need to worry about the database path change If you are filling the crystal report with the data table using the data source property. As I told you before that read the CR in VB.NET at my signature. In my first post I show a code that is filling the data using the data table in the crystal report so you have to no need to worry about the database path.
DL1600
Dec 3rd, 2006, 02:42 AM
Reading your tutorial in your signature is un-helpful. It displays coding and such with no instruciton. You should have "Step 1: Do this, Step 2: Do this and etc.." This "read my tutorial" does not help anyone, because the internet is useless as it is, because no one tags there websites correctly. For instance, you type "Crystal Reports in VB" in the search box, and you get "See Crystal naked". We would appreciate those of us who are advanced users, and seeked the answers from someone at one point in time to return the favor. This is how we all learn, and this is how the world can run a lot more smoothly.
bodylojohn
Dec 4th, 2006, 04:11 AM
Ok, I tried the following:
I added a new form to my project.
On that form I placed a CrystalReportViewer.
Then I created a report using the new report wizzard.
I made a connection using the 'create new connection'.
When I open the report it works and I get the data I want to see.
But here is my problem:
Now I select another database.
But my report shows the data of the database I set the connection in my crystal report to.
I used the following code:
Imports System.Data
Imports System.Data.OleDb
Public Class Report
Dim myConnection As New OleDb.OleDbConnection
Private Sub Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDatabasePath
myConnection.Open()
Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
CrystalReportViewer1.ActiveViewIndex = 0
CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
CrystalReportViewer1.Name = "CrystalReportViewer1"
Dim QueryString As String = "select * from tblLand" 'Your Query here
'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
'Connection.Open()
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
Dim DataSet As DataSet = New DataSet() 'DataSet
Adapter.Fill(DataSet)
Dim DataTable As DataTable = New DataTable 'DataTable
DataTable = DataSet.Tables(0) 'filling the datatable here
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
Report.SetDataSource(DataTable)
CrystalReportViewer1.ReportSource = Report
End Sub
End Class
shakti5385
Dec 5th, 2006, 02:04 AM
Now I select another database.
But my report shows the data of the database I set the connection in my crystal report to.
Be sure you are using the two database in one report or two table in one report??
I am confused here.
If there is two database then there is need of two connection.
bodylojohn
Dec 5th, 2006, 02:22 AM
I mean that I select the database from my programm when the database path changes.
The application should be flexible.
The report works on my computer.
But when I Deploy the application the user must select the database in HIS computer.
bodylojohn
Dec 6th, 2006, 03:12 AM
I hope some one can help me.
shakti5385
Dec 6th, 2006, 04:09 AM
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
Dim DataSet As DataSet = New DataSet() 'DataSet
Adapter.Fill(DataSet)
Dim DataTable As DataTable = New DataTable 'DataTable
DataTable = DataSet.Tables(0) 'filling the datatable here
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
Report.SetDataSource(DataTable)
CrystalReportViewer1.ReportSource = Report
Above code is correct for one table and this is working fine here, if you are using more then 2 table then do not declare the data set as new dataset second time
bodylojohn
Dec 7th, 2006, 12:47 AM
I tried your code on 1 table but it just doesnt work.
And what if I use more than 1 table???
Please help me guys. Its very important to me..
Thanks in advance...
shakti5385
Dec 7th, 2006, 12:53 AM
Please post me the whole code what you are using I want to check the code.
bodylojohn
Dec 7th, 2006, 01:35 AM
Hello,
This is my code....
I have a form called called 'Report'.
This form contains a CrystalReportViewer.
strDatabasePath containt the path to the database...
Imports System.Data
Imports System.Data.OleDb
Public Class Report
Dim myConnection As New OleDb.OleDbConnection
Private Sub Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDatabasePath
myConnection.Open()
Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
CrystalReportViewer1.ActiveViewIndex = 0
CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
CrystalReportViewer1.DisplayGroupTree = False
CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
CrystalReportViewer1.Name = "CrystalReportViewer1"
Dim QueryString As String = "select * from tblLand" 'Your Query here
'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
'Connection.Open()
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
Dim DataSet As DataSet = New DataSet() 'DataSet
Adapter.Fill(DataSet)
Dim DataTable As DataTable = New DataTable 'DataTable
DataTable = DataSet.Tables(0) 'filling the datatable here
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
Report.SetDataSource(DataTable)
CrystalReportViewer1.ReportSource = Report
End Sub
End Class
shakti5385
Dec 7th, 2006, 03:15 AM
Check the report location and save it at the application start up path.
bodylojohn
Dec 7th, 2006, 03:25 AM
The report is in the startuppath:
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here\
Did you find what I did wrong????
bodylojohn
Dec 7th, 2006, 03:27 AM
The Report works as long as I DONT change the database location.
And that is very importand that my application is very flexible.
shakti5385
Dec 7th, 2006, 03:38 AM
Dim QueryString As String = "select * from tblLand" 'Your Query here
'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
'Connection.Open()
Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
Dim DataSet As DataSet = New DataSet() 'DataSet
Adapter.Fill(DataSet,"tblLand")
'Dim DataTable As DataTable = New DataTable 'DataTable
'DataTable = DataSet.Tables(0) 'filling the datatable here
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
Report.SetDataSource(DataSet)
CrystalReportViewer1.ReportSource = Report
bodylojohn
Dec 10th, 2006, 05:09 AM
It still doesnt work.
The data of the connection that I made when I made the report is shown.
This is correct.
But when I Move the database to another path the report cant find the data.
This is my main problem.
I build the report using the wizzard.
I used 'create new connection'
This report works.
BUT...
When I instal the program on another pc no data is shown because my programm still looks to the connection that I made using the report wizzard.
I hope I explained my problem well enough???
Thanks in advance
bodylojohn
Dec 12th, 2006, 03:32 AM
Can anybody help me please????
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.