I am trying to display a Crystal Report developed using MySQL database and ASP.NET 2.0 (VS.NET 2005), and for some reason when I pass the database login information to the report it does not accept them (still shows a db login screen). Here is the code:

Dim cnString = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=servername;DATABASE=dbname;UID=user  name;PASSWORD=password;OPTION=3"
		Dim cn As New OdbcConnection(cnString)
		cn.Open()
		Dim MyReport As New CrystalDecisions.CrystalReports.Engine.ReportDocum  ent
		MyReport.Load("C:\Inetpub\wwwroot\Report1.rpt")
		MyReport.SetDataSource(cnString)
		MyReport.SetDatabaseLogon("username", "password")
		MyReport.SetParameterValue("parameter1", "1001")
		CrystalReportViewer1.ReportSource = MyReport
		CrystalReportViewer1.DataBind()
		cn.Close()

I have one Crystal Report Viewer and one Crystal Report Source objects on the form. The Crystal Report Source is set to "Report1.rpt" and the Viewer's source is set to that as well. When I run it, I get a parameter field request followed by a server login information request.

The actual Report properties are:

Database DLL: crdb_odbc.dll
DSN: NameOfDSNSource
UseDSNProperties: False
UserID: databaseUserName

I have even tried this:

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.IO
Imports MySql.Data.MySqlClient
 
' Class Name etc here ...
 
Dim conn As New MySqlConnection
 
		conn = New MySqlConnection("Server=servername; Database=dbname; User ID=dbuser; Password=dbpass; charset=utf8;")
		conn.Open()
		Dim MyReport As New CrystalDecisions.CrystalReports.Engine.ReportDocum  ent
		MyReport.Load("C:\Inetpub\wwwroot\Report1.rpt")
		MyReport.SetDataSource("Server=servername; Database=dbname; User ID=dbuser; Password=dbpass; charset=utf8;")
		MyReport.SetParameterValue("parameter1", "1001")
		CrystalReportViewer1.ReportSource = MyReport
		CrystalReportViewer1.DataBind()

But so far no luck. Does anyone know what the problem is with it? Any help would be appreciated.

Thank You

Have you tried just passing the database login for the crystal report?

Try this guide and see if it helps:

http://www.instantcrystal.net/instantguide.aspx

Thank you. I actually did solve my problem a few month ago. The only thing I was doing wrong was I was trying to pass the database login information to the report, while setting the wizard that comes with the Crystal Report Viewer at the same time! I took out the information in the wizard and it worked like a charm. :)

so what actually your problem? I have same problem that gives me login screen when i tried to show the report. Please tell me..

Hello Anli. As I said in the previous post:

The only thing I was doing wrong was I was trying to pass the database login information to the report, while setting the wizard that comes with the Crystal Report Viewer at the same time! I took out the information in the wizard and it worked like a charm.

By the way, I posted this thread in 2006, so it's been about 5 years since I actually had this problem. :)

Pete

Oh, thank you for your reply. I have found the solution. Just because i wrong write my DSN ODBC for MySQL. Once again thank you very much.

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.