Results 1 to 23 of 23

Thread: VB2005 No data in report

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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....

  2. #2
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Arrow 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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Re: VB2005 No data in report

    Hello,

    I have tried your code:

    VB Code:
    1. Imports System.Data
    2. Imports System.Data.OleDb
    3.  
    4. Public Class Form1
    5.  
    6.   Dim myConnection As New OleDb.OleDbConnection
    7.  
    8.   Public Sub FillDataset()
    9.     myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=H:\SOSOL\Klanten\Mutlu\Projecten\Textiel\BackUp\BU20061125\Data\Textielbedrijf2000.mdb"
    10.  
    11.     'Set the table adapters' connection
    12.  
    13.  
    14.     'Open connection
    15.     myConnection.Open()
    16.  
    17.     'Close the connection to the database
    18.     'myConnection.Close()
    19.   End Sub
    20.  
    21.   Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    22.     Call FillDataset()
    23.  
    24.     Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
    25.     Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    26.     CrystalReportViewer1.ActiveViewIndex = 0
    27.     CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    28.     CrystalReportViewer1.DisplayGroupTree = False
    29.     CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
    30.     CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
    31.     CrystalReportViewer1.Name = "CrystalReportViewer1"
    32.  
    33.     Dim QueryString As String = "select * from tblLand" 'Your Query here
    34.     'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
    35.     'Connection.Open()
    36.     Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
    37.     Dim DataSet As DataSet = New DataSet() 'DataSet
    38.     Adapter.Fill(DataSet)
    39.  
    40.     Dim DataTable As DataTable = New DataTable 'DataTable
    41.  
    42.     DataTable = DataSet.Tables(0) 'filling the datatable here
    43.  
    44.     Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
    45.     Report.SetDataSource(DataTable)
    46.     CrystalReportViewer1.ReportSource = Report
    47.  
    48.   End Sub
    49. End Class

    But it doesn't work.

    The report openes inside the crystalreportviewer but there is no data.
    Just the columnheaders.

  4. #4
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    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.

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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...

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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???

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Re: VB2005 No data in report

    Does anybody have a solution for my problem?

  8. #8
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up 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.

  9. #9
    Addicted Member
    Join Date
    Nov 2006
    Posts
    131

    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.

  10. #10

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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:
    1. Imports System.Data
    2. Imports System.Data.OleDb
    3.  
    4. Public Class Report
    5.   Dim myConnection As New OleDb.OleDbConnection
    6.  
    7.   Private Sub Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.     myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDatabasePath
    9.     myConnection.Open()
    10.  
    11.     Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
    12.     Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    13.     CrystalReportViewer1.ActiveViewIndex = 0
    14.     CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    15.     CrystalReportViewer1.DisplayGroupTree = False
    16.     CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
    17.     CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
    18.     CrystalReportViewer1.Name = "CrystalReportViewer1"
    19.  
    20.     Dim QueryString As String = "select * from tblLand" 'Your Query here
    21.     'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
    22.     'Connection.Open()
    23.     Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
    24.     Dim DataSet As DataSet = New DataSet() 'DataSet
    25.     Adapter.Fill(DataSet)
    26.  
    27.     Dim DataTable As DataTable = New DataTable 'DataTable
    28.  
    29.     DataTable = DataSet.Tables(0) 'filling the datatable here
    30.  
    31.     Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
    32.     Report.SetDataSource(DataTable)
    33.     CrystalReportViewer1.ReportSource = Report
    34.  
    35.   End Sub
    36. End Class

  11. #11
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up 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.

  12. #12

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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.

  13. #13

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Re: VB2005 No data in report

    I hope some one can help me.

  14. #14
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: VB2005 No data in report

    VB Code:
    1. Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
    2.     Dim DataSet As DataSet = New DataSet() 'DataSet
    3.     Adapter.Fill(DataSet)
    4.  
    5.     Dim DataTable As DataTable = New DataTable 'DataTable
    6.  
    7.     DataTable = DataSet.Tables(0) 'filling the datatable here
    8.  
    9.     Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
    10.     Report.SetDataSource(DataTable)
    11.     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

  15. #15

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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...

  16. #16
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: VB2005 No data in report

    Please post me the whole code what you are using I want to check the code.

  17. #17

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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:
    1. Imports System.Data
    2. Imports System.Data.OleDb
    3.  
    4. Public Class Report
    5.   Dim myConnection As New OleDb.OleDbConnection
    6.  
    7.   Private Sub Report_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    8.     myConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDatabasePath
    9.     myConnection.Open()
    10.  
    11.     Dim CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer = New CrystalDecisions.Windows.Forms.CrystalReportViewer
    12.     Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument = New CrystalDecisions.CrystalReports.Engine.ReportDocument
    13.     CrystalReportViewer1.ActiveViewIndex = 0
    14.     CrystalReportViewer1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    15.     CrystalReportViewer1.DisplayGroupTree = False
    16.     CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
    17.     CrystalReportViewer1.Location = New System.Drawing.Point(0, 0)
    18.     CrystalReportViewer1.Name = "CrystalReportViewer1"
    19.  
    20.     Dim QueryString As String = "select * from tblLand" 'Your Query here
    21.     'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
    22.     'Connection.Open()
    23.     Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
    24.     Dim DataSet As DataSet = New DataSet() 'DataSet
    25.     Adapter.Fill(DataSet)
    26.  
    27.     Dim DataTable As DataTable = New DataTable 'DataTable
    28.  
    29.     DataTable = DataSet.Tables(0) 'filling the datatable here
    30.  
    31.     Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
    32.     Report.SetDataSource(DataTable)
    33.     CrystalReportViewer1.ReportSource = Report
    34.  
    35.  
    36.   End Sub
    37.  
    38.  
    39. End Class

  18. #18
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Thumbs up Re: VB2005 No data in report

    Check the report location and save it at the application start up path.

  19. #19

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    Re: VB2005 No data in report

    The report is in the startuppath:

    VB Code:
    1. Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
    \

    Did you find what I did wrong????

  20. #20

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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.

  21. #21
    Just Married shakti5385's Avatar
    Join Date
    Mar 2006
    Location
    Udaipur,Rajasthan(INDIA)
    Posts
    3,747

    Re: VB2005 No data in report

    VB Code:
    1. Dim QueryString As String = "select * from tblLand" 'Your Query here
    2.     'Dim Connection As New OleDbConnection(funcs.con) 'Your Database Connection Here
    3.     'Connection.Open()
    4.     Dim Adapter As OleDbDataAdapter = New OleDbDataAdapter(QueryString, myConnection) 'Passing the query in the connection
    5.     Dim DataSet As DataSet = New DataSet() 'DataSet
    6.     Adapter.Fill(DataSet,"tblLand")
    7.  
    8.     'Dim DataTable As DataTable = New DataTable 'DataTable
    9.  
    10.     'DataTable = DataSet.Tables(0) 'filling the datatable here
    11.  
    12.     Report.Load(Application.StartupPath & "/CrystalReport1.rpt") 'Report Name Here
    13.     Report.SetDataSource(DataSet)
    14.     CrystalReportViewer1.ReportSource = Report

  22. #22

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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

  23. #23

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2006
    Location
    Netherlands
    Posts
    817

    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
  •  



Click Here to Expand Forum to Full Width