I'm working with a very basic app to learn about putting Crystal Reports in my applications. I have a Windows application with a single form with a combo box, a button, and a Crystal Report Viewer on it. I have a very simple Crystal Report that I developed using Crystal 8.5...this report accepts a single parameter. (I want to be able to develop and edit my reports outside of Visual Studio and then link to them from the application so that report changes do not require a program recompile.)
Everything was working fine until, I tried to change the database connection settings for the Crystal Report via program code. Now, when I run the program, I get a "Database Login" dialog box. This box has the following fields on it:
Table Name: imitmidx_sql (and I can not change this table name..though it is one of the 3 tables the report uses)
Server Name: jamesdell (I can change this, though it is correct)
Database: (this is blank, so I type in 001 which is the database I want to connect to)
Login ID: sa (I can change this, though it is correct)
Password: (this is blank, but is correct for my local SQL Server)
No matter what I do, once I click the Finish button I get, "Logon Failed. Please try again."
Below is the code I'm using to load the crystal report:
Private Sub btnGo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGo.Click
'Load the report
'Setup the connection information.
crConnectionInfo = New ConnectionInfo
.ServerName = "jamesdell"
.DatabaseName = "001"
.UserID = "sa"
.Password = ""
'Get the table information from the report
crDatabase = crReportDocument.Database
crTables = crDatabase.Tables
'Loop thru all tables in the report and apply the connection information for each table.
For Each crTable In crTables
crTableLogOnInfo = crTable.LogOnInfo
crTableLogOnInfo.ConnectionInfo = crConnectionInfo
'Set the parameter field definitions
'Bind the report to the viewer
CrystalReportViewer1.ReportSource = crReportDocument