|
-
Nov 25th, 2006, 07:06 AM
#1
Thread Starter
Fanatic Member
VB2005 No data in report
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....
-
Nov 25th, 2006, 07:32 AM
#2
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.
-
Nov 25th, 2006, 07:40 AM
#3
Thread Starter
Fanatic Member
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.
-
Nov 25th, 2006, 09:05 AM
#4
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.
-
Nov 25th, 2006, 10:08 AM
#5
Thread Starter
Fanatic Member
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...
-
Nov 25th, 2006, 11:19 AM
#6
Thread Starter
Fanatic Member
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???
-
Nov 30th, 2006, 08:10 AM
#7
Thread Starter
Fanatic Member
Re: VB2005 No data in report
Does anybody have a solution for my problem?
-
Nov 30th, 2006, 08:21 AM
#8
Re: VB2005 No data in report
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.
-
Dec 3rd, 2006, 03:42 AM
#9
Addicted Member
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.
-
Dec 4th, 2006, 05:11 AM
#10
Thread Starter
Fanatic Member
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
-
Dec 5th, 2006, 03:04 AM
#11
Re: VB2005 No data in report
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.
-
Dec 5th, 2006, 03:22 AM
#12
Thread Starter
Fanatic Member
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.
-
Dec 6th, 2006, 04:12 AM
#13
Thread Starter
Fanatic Member
Re: VB2005 No data in report
I hope some one can help me.
-
Dec 6th, 2006, 05:09 AM
#14
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
-
Dec 7th, 2006, 01:47 AM
#15
Thread Starter
Fanatic Member
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...
-
Dec 7th, 2006, 01:53 AM
#16
Re: VB2005 No data in report
Please post me the whole code what you are using I want to check the code.
-
Dec 7th, 2006, 02:35 AM
#17
Thread Starter
Fanatic Member
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
-
Dec 7th, 2006, 04:15 AM
#18
Re: VB2005 No data in report
Check the report location and save it at the application start up path.
-
Dec 7th, 2006, 04:25 AM
#19
Thread Starter
Fanatic Member
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????
-
Dec 7th, 2006, 04:27 AM
#20
Thread Starter
Fanatic Member
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.
-
Dec 7th, 2006, 04:38 AM
#21
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
-
Dec 10th, 2006, 06:09 AM
#22
Thread Starter
Fanatic Member
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
-
Dec 12th, 2006, 04:32 AM
#23
Thread Starter
Fanatic Member
Re: VB2005 No data in report
Can anybody help me please????
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|