• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1205
  • Last Modified:

Crystal Reports.NET - logon screen promt on client machine - database field empty

Good Day Experts

I've developed a windows application using C# and crystal reports.net.  On my dev pc, the crystal reports execute without any problems.  After installing it on the client's machine, I get the attached logon promt asking to enter the database details (crystal logon screen promt.gif).  The username and password, as well as the server ip address is correct.  The problem, I think, is that the database name on this screen is empty, and I have no idea why that would be the case.  I'm connecting to SQL Server 2005 that sits on a remove server (provided by my service provider that also hosts the web site of this client).

I've included the code that provides the crystal report with the correct connection details to the database (I've starred out the password).  In this code, you'll see that the correct database name is passed to the report.  The source of this report is a stored procedure with 2 parameters (code to supply parameter values are also included).

Attached is also a screen shot of the setup I created to install the application on the client's pc (Setup.gif).  I've included the crystal merge modules for the database acess.  I've also included the install of the Crystal Reports Runtime files: CRRedist2008_x86.msi on the client's pc, without any success.

Could you please let me know if there is something in the installation setup of this application that I missed?

Thank you very much.

Kind regards
Daleen van Zyl
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Configuration;
 
namespace RetreadReconciliation
{
	public partial class frmReportViewer : Form
	{
		public string selectedReport;
		public ReportDocument oRpt = null;
 
		private string StatusID = string.Empty;
		private string ClientID = string.Empty;
		private string ReportPath = string.Empty;
 
		public frmReportViewer()
		{
			InitializeComponent();
			ReportPath = ConfigurationSettings.AppSettings["ReportPath"];
		}
public void RunReport(bool bQuery, string sWhereClause)
		{
			this.Cursor = Cursors.WaitCursor;
			oRpt = new ReportDocument();
			try
			{
				oRpt.Load(ReportPath + "rptQueryReport.rpt");
				SetLogonInfo(oRpt);
				SetParameterFields(bQuery, sWhereClause);
				this.crViewer.ReportSource = oRpt;
			}
			catch (Exception ex)
			{
				throw new Exception(ex.Message.ToString());
			}
			this.Cursor = Cursors.Default;
		}
		private void SetLogonInfo(ReportDocument rpt)
		{
			TableLogOnInfo logonInfo = new TableLogOnInfo();
			TableLogOnInfos logonInfos = new TableLogOnInfos();
			ConnectionInfo connectionInfo = new ConnectionInfo();
 
			connectionInfo.ServerName = "208.101.12.227";
			connectionInfo.DatabaseName = "vttyreservices";
			connectionInfo.UserID = "vttyre";
			connectionInfo.Password = "************";
 
			SetDBLogonForReport(connectionInfo, rpt);
			this.crViewer.ReportSource = rpt;
		}
		private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
		{
			Tables tables = reportDocument.Database.Tables;
			foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
			{
				TableLogOnInfo tableLogonInfo = table.LogOnInfo;
				tableLogonInfo.ConnectionInfo = connectionInfo;
				table.ApplyLogOnInfo(tableLogonInfo);
			}
		}
private void SetParameterFields(bool bQuery, string sWhereClause)
		{
			ParameterFields paramFields;
			ParameterField paramFieldWhereClause;
			ParameterField paramFieldDebug;
			ParameterDiscreteValue paramDiscreteValueWhereClause;
			ParameterDiscreteValue paramDiscreteValueDebug;
 
			paramFields = new ParameterFields();
 
			paramFieldWhereClause = new ParameterField();
			paramDiscreteValueWhereClause = new ParameterDiscreteValue();
			paramFieldWhereClause.Name = "@WhereClause";
			paramDiscreteValueWhereClause.Value = sWhereClause;
			paramFieldWhereClause.CurrentValues.Add(paramDiscreteValueWhereClause);
 
			paramFieldDebug = new ParameterField();
			paramDiscreteValueDebug = new ParameterDiscreteValue();
			paramFieldDebug.Name = "@Debug";
			paramDiscreteValueDebug.Value = "0";
			paramFieldDebug.CurrentValues.Add(paramDiscreteValueDebug);
 
			//Add the paramField to paramFields
			paramFields.Add(paramFieldWhereClause);
			paramFields.Add(paramFieldDebug);
 
			crViewer.ParameterFieldInfo = paramFields;
		}
}

Open in new window

crystal-logon-screen-promt.gif
Setup.gif
0
datacashdeveloper
Asked:
datacashdeveloper
  • 10
  • 6
7 Solutions
 
mlmccCommented:
If you click OK does the report show?

mlmcc
0
 
datacashdeveloperAuthor Commented:
Hi, mlmcc
If I click on the "Finish" button, the window I attached earlier, keeps on showing, so when I click on the "Cancel" button, I get a screen saying "Logon failed.  Please try again".  If I then click on the OK button, then I get an empty screen where the report should be - only the viewer control shows. (screen shot attached - empty report.gif).
Regards
Daleen

empty-report.gif
0
 
mlmccCommented:
Try removing the setting of the viewer to the report in the DatabaseLogon subroutine

mlmcc
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
datacashdeveloperAuthor Commented:
Hi, mlmcc
Thank you.  I'll do that and test my solution again.
I will let you know what the outcome is.
Regards
Daleen
0
 
datacashdeveloperAuthor Commented:
Hi, mlmcc
I removed the line of code this.crViewer.ReportSource = rpt in the SetLogonInfo subroutine, but now the report shows nothing at all.  The same empty screen shows now as the previous attachment (empty-report.gif).  So I'm afraid it did not work.
Regards
Daleen
0
 
datacashdeveloperAuthor Commented:
Hi, mlmcc
My apologies, the report showed the correct values on my development machine.  On the client's machine, it still asks for the logon details and the Database field on the logon screen is still empty (as per attachment: crystal-logon-screen-promt.gif).  The same simptoms as before I removed the line of code you suggested.
Regards
Daleen
0
 
mlmccCommented:
I assume the user has access to that database?

mlmcc
0
 
datacashdeveloperAuthor Commented:
Hi, mlmcc
Yes, the user has access to the database.  All the database lookups within the application works 100% - only the crystal report does not work.
Regards
Daleen
0
 
datacashdeveloperAuthor Commented:
mlmcc
Just one other thing - I think there is there something I need to install on the client's machine for this to work, but I do not know what it is.  There must be something installed on my dev box that makes the reports work.  I think the problem lies with the fact that the Database text box on the db logon screen promt is empty - so the report does not know to which database on that db server it needs to connect to, although I do set it in the code.
Daleen
0
 
mlmccCommented:
How did you install on the user's box?

Did you build an installatiion package?

Did you use the merge modules?

mlmcc
0
 
datacashdeveloperAuthor Commented:
Hi mlmcc
Yes, I built a package with the merge modules - look at my first post - the screen shot of the installation package is included in that post.
Regards
Daleen
0
 
mlmccCommented:
I don't know.

mlmcc
0
 
datacashdeveloperAuthor Commented:
Hi, mlmcc
Thank you.  I'll have a look and let you know.
(Sorry for the late reply - I did not for some reason receive the email notification that you've added a comment.)
Regards
Daleen
0
 
datacashdeveloperAuthor Commented:
Hi, mlmcc
Unfortunately the article you found did not help to solve my problem.
Thank you very much for your assistance.
Regards
Daleen
0
 
datacashdeveloperAuthor Commented:
There is no solution to this problem.
Regards
Daleen
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 10
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now