Click here to Skip to main content
15,444,353 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using Visual Studio 2008. When I run my project in client machine I'm getting this error, when try to print the report. This is working fine in my machine.
I have installed CR Runtime in client machine.
------------------------------------------------------------------------------
Crystal Report Windows Forms Viewer.

Error in File:C:\Users\Nuwan\AppData\Local\Temp\rptInvoice{C51266F3-E2EE-4A02-B5CF-12BCE727360C}.rpt: Unable to connect : incorrect logon parameters.

----------------------------------------------------------------------------------

This is my code part.

------------------------------------------------------------------------------------
C#
try
{

    ReportDocument cryRpt = new ReportDocument();
    cryRpt.Load(@"rptDNote.rpt");
    ParameterFieldDefinitions crParameterFieldDefinitions;
    ParameterFieldDefinition crParameterFieldDefinition;
    ParameterValues crParameterValues = new ParameterValues();
    ParameterDiscreteValue crParameterDiscreteValue = new ParameterDiscreteValue();

    crParameterDiscreteValue.Value = int.Parse(cmbInvoNo.Text);
    crParameterFieldDefinitions = cryRpt.DataDefinition.ParameterFields;
    crParameterFieldDefinition = crParameterFieldDefinitions["InvoNo"];
    crParameterValues = crParameterFieldDefinition.CurrentValues;

    crParameterValues.Clear();
    crParameterValues.Add(crParameterDiscreteValue);
    crParameterFieldDefinition.ApplyCurrentValues(crParameterValues);

    crystalReportViewer1.Refresh();
    crystalReportViewer1.ReportSource = cryRpt;
    crystalReportViewer1.PrintReport();
}
catch (Exception ex)
{
    MessageBox.Show(ex.ToString());
}
Posted
Updated 13-Feb-12 2:08am
v2

1 solution

Since the server is different from your development server and the client server. You should instruct you crystal report object to use different connection info. Try to use this code. I suggest to store credential on your app config. I hope this helps.

C#
ConnectionInfo crConnectionInfo = new ConnectionInfo();
crConnectionInfo.ServerName = "YOUR SERVER NAME";
crConnectionInfo.DatabaseName = "YOUR DATABASE NAME";
crConnectionInfo.UserID = "YOUR DATABASE USERNAME";
crConnectionInfo.Password = "YOUR DATABASE PASSWORD";
CrTables = cryRpt.Database.Tables ;
foreach (CrystalDecisions.CrystalReports.Engine.Table CrTable in CrTables)
{
    crtableLogoninfo = CrTable.LogOnInfo;
    crtableLogoninfo.ConnectionInfo = crConnectionInfo;
    CrTable.ApplyLogOnInfo(crtableLogoninfo);
}
 
Share this answer
 
Comments
ldsroshan 13-Feb-12 19:10pm    
Please explain what are the data types of 'CrTables' and 'crtableLogoninfo'. Thanks.
ldsroshan 13-Feb-12 19:59pm     CRLF
I found it. Thanks for the help. //------------ TableLogOnInfo crtableLogoninfo = new TableLogOnInfo(); Tables CrTables; //----------------
Michael dg 14-Feb-12 2:06am    
sorry i forgot to put the data types of those variables.
Member 10577976 26-Mar-14 6:02am    
It's not working..I am getting same error when Run the program

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900