I use Visual basic 8.0, Cyrstal Reports v10 what is included in Visual basic 8.0 and MYSQL 5.0.
I have installed :mysql-connector-odbc-5.1.5-win32.msi

I have database Articles with two fields:
article nr
article discription

To connect to my MYSQL database within My form i use this:
Dim Myconn As New MySqlConnection
Dim myCommand As New MySqlCommand
Dim myAdapter As New MySqlDataAdapter
Dim myData As New DataTable
Dim MyConnString As String

MyConnString = "port=3306;SERVER=localhost ;DATABASE=Articles; Uid=test;Pwd=test"
Myconn.ConnectionString = MyConnString
End so on.


The only thing i want to do is connect to MYSQL database to my Cyrstal report. So these two fields can added to my report.
article nr
article discription

But evertime do this :
start with "crystal report design"
I select "Data"
"add new datasource"
I select "Database"
I select "New connection"
I choose datasource "Mysql database"
add connection (see Annex) I come up here
I cannot fill in Server name, user Name, password Database name.
evertime i try to type something de system jump back to previous screen

Please can some body help with this.

kvprajapati commented: Use code tags. -1

Recommended Answers

All 5 Replies

I'm not sure what is causing your datasource problem with crystal reports but just to offer an alternative suggestion...

When I create a crystal report I dont even assign it to a datasource or database; instead I connect it to a dataset. Then in my program, I fill my dataset to display to users and when there ready for the report, I just pass the filled dataset as the datasource. This has a few advantages such as the report not having to connect to the db and requery info that you may already be working with in a program.

I'm not sure what is causing your datasource problem with crystal reports but just to offer an alternative suggestion...

When I create a crystal report I dont even assign it to a datasource or database; instead I connect it to a dataset. Then in my program, I fill my dataset to display to users and when there ready for the report, I just pass the filled dataset as the datasource. This has a few advantages such as the report not having to connect to the db and requery info that you may already be working with in a program.

Two Questions:
1.Can you show me how to do that?
2.How can you then add datafields to you crystal report if you designing a report?

Are you familar with Typed Datasets within your project? I add a dataset file to my project and create some tables within it to match the db tables & fields I want to work with in the database. Thats it.... (besides of course my coding to fill & work with the dataset but thats done elsewhere in my projects)

When you create a new report and the wizard dialog asks for a datasource, you will see that one of the options is for Ado.Net datasets, you can navigate directly to the dataset file within your project or point it to any dataset file (.xsd) file from any other project on your PC.

Your report will then have all the tables & fields available to you that are included in that dataset to work with although the dataset file itself is not directly connected to any info.

Are you familar with Typed Datasets within your project? I add a dataset file to my project and create some tables within it to match the db tables & fields I want to work with in the database. Thats it.... (besides of course my coding to fill & work with the dataset but thats done elsewhere in my projects)

When you create a new report and the wizard dialog asks for a datasource, you will see that one of the options is for Ado.Net datasets, you can navigate directly to the dataset file within your project or point it to any dataset file (.xsd) file from any other project on your PC.

Your report will then have all the tables & fields available to you that are included in that dataset to work with although the dataset file itself is not directly connected to any info.

Thanks to so far , I am little bit further now!!.
ps. name of my project is "rapport"
Here is my source and a annex with the problem.

Dim myConn As New MySqlConnection
        Dim myCommand1 As New MySqlCommand
        Dim myAdapter1 As New MySqlDataAdapter
        Dim myData1 As New DataTable
        Dim MyConnString, MySQLstring1 As String
        Dim MyDS As New DataSet1()
        Dim CRreport As New CrystalReport1

       MyConnString= "server=localhost;database=test;uid="";password="""
        myConn.ConnectionString = MyConnString
        MySQLstring1 = "SELECT * FROM naw"
        myCommand1.Connection = myConn
        myCommand1.CommandText = MySQLstring1
        myAdapter1.SelectCommand = myCommand1
        myAdapter1.Fill(MyDS, "NAW")
        CRreport.SetDataSource(MyDS)
        crystalReportViewer1.ReportSource = CRreport

But I do not see anny tables in the data expert (see annex) What is wrong?

Seems like a silly question but did you actually create any tables within your dataset?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.