Click here to Skip to main content
15,887,240 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a form called frmviewreport.vb and I have placed on it the CrytalReportViewer named rptViewer.

I want to show a record on the report viewer from data I get from MySQl db.

Thanks in advance.
Posted
Updated 24-May-11 3:10am
v2
Comments
Karwa_Vivek 24-May-11 2:44am    
have you Designed your Crystal report

which you need to Show inside the CRviewer
joseph k 24-May-11 3:04am    
Well, i just placed the report viewer inside the form. I have never done this before, please guide me to design the report first.
Dalek Dave 24-May-11 9:10am    
Edited for Grammar and Readability.

If you are a beginner in this Subject then
you must visit this link [^]
and From Crystal reports to what ever your need you will learn it
from here stepwise and in easy way
Best of luck
and have Fun..
 
Share this answer
 
v2
Comments
joseph k 24-May-11 4:03am    
Great help, i have completed the tutorials and currently using ODBC Mysql Connector to connect to DB and get report data.
Now, what if i want to place a search BOx on my form so the report can show that record only.
Dalek Dave 24-May-11 9:10am    
Good Link
For this you have to use
Crystal Reports from SQL Query String
which can be found here in this link [^]
pass the query and in where condition put the required field on which you want to search
 
Share this answer
 
Comments
joseph k 24-May-11 8:55am    
This is getting sweeter:
I followed instructions on this page for C#
http://www.codeproject.com/KB/database/MySQLCrystal.aspx
When i reached the title "Display Report in the Form"
I could not figure out how to do that and you gave me the link above : http://vb.net-informations.com/crystal-report/crystal_report_from_sql_query_string.htm
and i got the code just the last four lines of the sub routine.
I would like to thank all you guys for helping me. Finally let me just describe what i did to solve this problem of VB.NET, Crystal Reports and MySQL:


I followed instructions on this page for C# on this link http://www.codeproject.com/KB/database/MySQLCrystal.aspx
and the code on this link (i just used the last four lines of the subroutine) http://vb.net-informations.com/crystal-report/crystal_report_from_sql_query_string.htm

and made the code for VB.NET as follows:
VB
Imports CrystalDecisions.CrystalReports.Engine
Imports MySql.Data.MySqlClient
Public Class frmViewReport
    Dim conn As MySqlConnection
    Dim daCompanies As New MySqlDataAdapter()
    Dim dsCompanies As New DataSet()

    Private Sub frmViewReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        conn = New MySqlConnection

        Try
            With conn
                If .State = ConnectionState.Open Then .Close()

                .ConnectionString = cnString
                .Open()
            End With
        Catch ex As MySqlException
            MsgBox(ex.ToString)
        End Try
        Try
            Dim qryCompanies As String = "SELECT * FROM `tbl_permits`"

            daCompanies.SelectCommand = New MySqlCommand(qryCompanies, conn)

            Dim cb As MySqlCommandBuilder = New MySqlCommandBuilder(daCompanies)

            daCompanies.Fill(dsCompanies, "tbl_permits")
        Catch ex As MySqlException
            MsgBox(ex.ToString)
        Finally
            conn.Close()
        End Try

        Dim objRpt As New Permit
        objRpt.SetDataSource(dsCompanies.Tables("tbl_permits"))
        rptViewer.ReportSource = objRpt
        rptViewer.Refresh()

  'This is the other Option i did not use... But it worked.
        'Dim cryRpt As New ReportDocument
        'cryRpt.Load("C:\Users\Josh\Documents\Visual Studio 2008\Projects\WindowsApplication1\WindowsApplication1\Permit.rpt")
        'rptViewer.ReportSource = cryRpt
        'rptViewer.Refresh()
    End Sub
End Class


I hope this would be useful for someone else......
 
Share this answer
 
Comments
Karwa_Vivek 24-May-11 9:08am    
Really !!!
Interesting..
 
Share this answer
 
Comments
joseph k 24-May-11 3:07am    
Let me go through it, Can i mix C and VB codes?? I hope its going to be easy to translate to vb.net
Abhinav S 24-May-11 7:29am    
You can actually mix C# and VB.Net code. But converting it to VB.Net should not be too difficult.
Now, am just wondering what is the left pane (white section) on the left of the Crystal Report Viewer is used for, Am putting a button and textbox there but i feel there is something else i dont know what its for??
 
Share this answer
 
Comments
Karwa_Vivek 24-May-11 9:31am    
Is this your Solution ?
Karwa_Vivek 24-May-11 9:36am    
but for your Info
it is Called as Group tree.Ask your question at a proper place.
joseph k 24-May-11 9:50am    
Yes it is my solution and i have been here alone while i asked questions and read the tutorials. I think you are wondering why am asking about the white pane... ehehe.... Yes i added the Crystal Report Viewer and definitely it comes with that section AND i was just wondering what is the the use of it because when i open the report it is blank white, it has nothing and i want to know everything so that i don't come back to the same questions again.. I want to make my report look nice since i have learnt the various ways of putting data to it, i want to make more useful to the user. For your information, i only have a basic knowledge in MsAccess Programming. I have never used this .NET before and Crystal Reports, I have just heard of them and now was my time to learn it by myself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900