Link to home
Start Free TrialLog in
Avatar of msmpc
msmpc

asked on

Why does the "Database Login" box keep popping up...and doesn't accept my login credentials

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
            crReportDocument.Load("C:\Program Files\MSMPC\rpt\MSMOEINV.rpt")

            'Setup the connection information.
            crConnectionInfo = New ConnectionInfo
            With crConnectionInfo
                .ServerName = "jamesdell"
                .DatabaseName = "001"
                .UserID = "sa"
                .Password = ""
            End With

            '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
                crTable.ApplyLogOnInfo(crTableLogOnInfo)
            Next

            'Set the parameter field definitions
            crReportDocument.SetParameterValue("inv_no", cboInvoices.SelectedItem)

            'Bind the report to the viewer
            CrystalReportViewer1.ReportSource = crReportDocument
End Sub
Avatar of Mike McCracken
Mike McCracken

I suspect you didn't set your table location properly. try append the table location as below:

For Each crTable In crTables
      crTableLogOnInfo = crTable.LogOnInfo
      crTableLogOnInfo.ConnectionInfo = crConnectionInfo
      crTable.ApplyLogOnInfo(crTableLogOnInfo)
      crTable.Location = crTableLogOnInfo.TableName;
Next

dylan
Avatar of msmpc

ASKER

mlmcc...I looked over the link...I don't know what Report Designer Component 6 is...how do I know what version I'm using...also, if I try to use their code, I get an "is not defined" with the  Craxdrt part in "Dim crTable As Craxdrt.DatabaseTable "

dylan...if I add the line "crTable.Location = crTableLogOnInfo.TableName", my app throws an exception "Invalid table number"
Do you have subreport in your report? If so, you have to apply the same table logon info the tables in subreport.

dylan
Avatar of msmpc

ASKER

no subreport...I've created the report as simply as I can, just to create a sample project demonstrating how to have a Crystal Report in a vb.net application.  The report has a single parameter and displays one field from each of 3 linked tables. I have an order header, order line, and item table.  I'm trying to show the customer number (from header), item number (from line), and item description (from item) where the invoice number field in the header table (this value is unique in this table) matches the parameter value (taken from a combo box on the form)

I'm beginning to wonder it this is related to the fact that my Crystal Report was created using a Crystal Reports 8.5 and is being linked to the vb.net project with the crReportDocument.Load("C:\Program Files\MSMPC\rpt\MSMOEINV.rpt") statement.  Is there some references or namespaces that must be included for a CR 8.5 report?
Avatar of msmpc

ASKER

ok...problem seems to be solved.  I created the report with Crystal 10 and made no changes to the vb.net code and now it works.  Now that I think of it, seems like I read somewhere on this site that Crystal 8.5 was not supported in .NET.

CR 8.5 is supported in VS.NET 2002/2003, I am not sure about VS.NET 2005.
If you are using VS.NET 2005, it might not provide backward support for some of the feature in CR 8.5 snice VS.NET 2005 comes together with CR10.

dylan
Avatar of msmpc

ASKER

I'm using VS.NET 2003.  All I can say is, I uninstalled Crystal 8.5 and installed Crystal 10 just out of frustration and now it seems to be working fine.
ASKER CERTIFIED SOLUTION
Avatar of GranMod
GranMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial