Re: VB2005 No data in report
Have you connect the report with the database. Read the CR In VB.Net at my signature for more detail.
Re: VB2005 No data in report
Hello,
I have tried your code:
VB 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.
Re: VB2005 No data in report
Check the datatable trace the code if you are getting the data in the datatable then the record will appear in the Cr also.
Re: VB2005 No data in report
The dataTable has data in it.
I also see the 2 columnheaders in the crystalreportviewer.
But I just dont see any data...
Re: VB2005 No data in report
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???
Re: VB2005 No data in report
Does anybody have a solution for my problem?
Re: VB2005 No data in report
Quote:
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.
Re: VB2005 No data in report
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.
Re: VB2005 No data in report
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:
VB 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
Re: VB2005 No data in report
Quote:
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.
Re: VB2005 No data in report
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.
Re: VB2005 No data in report
I hope some one can help me.
Re: VB2005 No data in report
VB Code:
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
Re: VB2005 No data in report
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...
Re: VB2005 No data in report
Please post me the whole code what you are using I want to check the code.
Re: VB2005 No data in report
Hello,
This is my code....
I have a form called called 'Report'.
This form contains a CrystalReportViewer.
strDatabasePath containt the path to the database...
VB 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
Re: VB2005 No data in report
Check the report location and save it at the application start up path.
Re: VB2005 No data in report
The report is in the startuppath:
VB Code:
Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
\
Did you find what I did wrong????
Re: VB2005 No data in report
The Report works as long as I DONT change the database location.
And that is very importand that my application is very flexible.
Re: VB2005 No data in report
VB Code:
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
Re: VB2005 No data in report
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
Re: VB2005 No data in report
Can anybody help me please????