Search code examples
mysqlvb.netcrystal-reports

"Database logon failed" in Crystal Reports when using System DSN for MySQL Server


I'm trying to create VB.Net app with crystal reports and MySQL as the database. I tried connecting Crystal report and MySQL database through various available methods but only DSN method got successful(Partially).

I have created a 64bit System DSN and linked that to crystal report in VB.Net 2022. In the design view, I can see the report with data.

enter image description here

However, when I try to run and view the report, following happens.

  1. Crystal report again asks for the logon credentials. enter image description here
  2. Get a "Logon failure" error even after giving the correct credentials. enter image description here

I also set the logon credentials at the run time using following code.

   Dim rep As New crRepAllBooks
   rep.SetDatabaseLogon("root", "xxxxxxxxx", "localhost", "lms")
   CrystalReportViewer1.ReportSource = rep
   rep.Refresh()

I also tested it with a 32bit DSN with same results. I'm using any CPU option.

enter image description here

enter image description here Can some one kindly explain me how to do this properly without getting the prompt to enter credentials.


Solution

  • You are probably not building the application in Release mode as a 64-bit application.

    You stated that you created a 64-bit DSN, and Visual Studio is running as a 64-bit application, so everything works fine in the debugger.

    However, if you don't specify to build the .EXE in 64-bit mode, you may end up with a 32-bit executable trying to use the 64-bit DSN, which won't work.

    You'll either have to specify Release mode to build a 64-bit application, or also create a 32-bit DSN.