Click here to Skip to main content
15,173,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,
Please I am desperate for help

I am new to Crystal and I am having so many issues without finding the correct solution!!!

I have developed a windows form c# 2010 app that shows crystal 10 and the database is FOXPRO.

I am trying to set the logon details in the code as the datasource location can change, however I keep getting "Logon Failed" and I don't understand why

Please I need help!!!!!

Also, I tried to run my app in the client's machine (win 7 64bit) and I am not able to run the crystal reports, I get error with crystaldecisions*dll & shared*dll

I don't know what else do I have to install, I already installed sap crystal .net framework 4 it's still not working, I don't want to have to install Crystal in the client's machine. What am I missing?

I am so sick of searching, as there are so many different solutions and also they did not work for me!!!

Please please please help me!

Thank you!!!
Sahira Zaman
Posted
Comments
Sushil Mate 12-Jul-13 1:37am
   
1) you need to install crystal report setup at clients machine (64bit).
2) check the connection string at clients side, that must be wrong.
Sahira Zaman 12-Jul-13 2:24am
   
Hi Sushil Mate, thanks for your reply

1)I have tried many versions of crystal setup without success, I need a step by step however I could not find one with the links to the correct setup. I am sorry, but I have had this issue for a month already and I am very sick of it.
2)I have another question, if the data source location in the file "*.rpt" is incorrect, will that work if I set the location in my application, via code? The application will be installed in different clients and they all will have their own database location (which is foxpro = *.dbf files). Or could I send the data source location via parameter to the report? If so, how do I set this in the report?

Your help is very much appreciated

Thanks again :)
Sushil Mate 12-Jul-13 3:20am
   
please see my answer. if you face any issue let me know.
Sahira Zaman 12-Jul-13 3:46am
   
Thank you :) I will check it all and let you know how it goes, thanks a lot!!!!!

Here is the solution for issue number 1) "Logon failed" using fox pro and crystal in c#
C#
//set only the server name for all tables including DB path + file name (*.dbf)
                    ReportDocument doc = new ReportDocument();
                    ParameterFields paramFields = new ParameterFields();
                    string[] sParamArr = null;

                    doc.Load(frmMainButton._initialParam.ReportLocation + @"\" + _reportName.ToLower());

                    //Tables tables = doc.Database.Tables;
                    foreach (CrystalDecisions.CrystalReports.Engine.Table table in doc.Database.Tables)
                    {
                        table.LogOnInfo.ConnectionInfo.ServerName = frmMainButton._initialParam.DBDataSource + @"\" + table.LogOnInfo.TableName.ToString() + ".DBF";
                        table.ApplyLogOnInfo(table.LogOnInfo);
                    }

                    try
                    {
                        doc.Refresh();
                        doc.VerifyDatabase();
                    }
                    catch (LogOnException engEx)
                    {
                        MessageBox.Show("Incorrect Logon Parameters. Check your user name and password.");
                    }

                    if (_parametersList.Count > 0)
                    {
                        foreach (string s in _parametersList)
                        {
                            sParamArr = s.Split('|');

                            ParameterField pField = new ParameterField();
                            pField.Name = sParamArr[0];
                            pField.ParameterFieldName = sParamArr[0];
                          
                            ParameterDiscreteValue pDValue = new ParameterDiscreteValue();
                            pDValue.Value = sParamArr[1];
                            pField.CurrentValues.Add(pDValue);
                            pField.ReportParameterType = ParameterType.QueryParameter;
                            pField.IsOptionalPrompt = true;
                            pField.HasCurrentValue = true;
                            pField.EnableNullValue = true;
                            
                            paramFields.Add(pField);

                            doc.SetParameterValue(sParamArr[0], sParamArr[1]);
                        }
                        _parametersList.Clear();
                    }
                    
                    doc.Refresh();
                    crystalReportViewer.UseWaitCursor = true;
                    crystalReportViewer.ParameterFieldInfo = paramFields;
                    crystalReportViewer.ReportSource = doc;                    
                    crystalReportViewer.RefreshReport();
                    crystalReportViewer.UseWaitCursor = false;
   
v2
First of all you need to learn how to use crystal report in the .net, Below I have given some links. Please go through it.

1) C# crystal reports step by step.[^]

This link has detailed information on Crystal Report.
2) Generate a Report using Crystal Reports in Visual Studio 2010[^]

3) How to create basic crystal report[^]

This version little bit old but it helps you to get deep understanding of deployment of Crystal report.
4) Crystal Report 2005 Deployment Guide.[^]

5) Using Crystal Reports with VFP[^]

6) Crystal Report Deployment in VS 2010.[^]



Quote:
I have another question, if the data source location in the file "*.rpt" is incorrect, will that work if I set the location in my application, via code?
You can do that.

Please read above the articles it will helpful to resolve your issue. There are very less information on Crystal report with FoxPro. Most people go with .Net + Crystal report with SQL.
   
v3
Comments
Sahira Zaman 13-Jul-13 9:25am
   
Hi Sushil, hope you are well.

I have gone through all the links and I managed to open the report from different data sources in real time by adding the file name "*.dbf" to the connection string, however I still have 2 problems:

1. I get "Logon failed" from Crystal form when loading the report
2. It keeps popping up the parameters screen, but I am sending them to the report

Hope you can help me once more :)

My code:

ReportDocument doc = new ReportDocument();
ParameterFields paramFields = new ParameterFields();
string[] sParamArr = null;

doc.Load(frmMainButton._initialParam.ReportLocation + @"\" + _reportName.ToLower());
crystalReportViewer.RefreshReport();
if (_parametersList.Count > 0)
{
foreach (string s in _parametersList)
{
sParamArr = s.Split('|');

ParameterField pField = new ParameterField();
pField.Name = sParamArr[0];
pField.ParameterFieldName = sParamArr[0];
pField.ParameterValueType = ParameterValueKind.StringParameter;
pField.PromptText = sParamArr[1];

ParameterDiscreteValue pDValue = new ParameterDiscreteValue();
pDValue.Value = sParamArr[1];
pField.CurrentValues.Add(pDValue);
paramFields.Add(pField);
}
_parametersList.Clear();
}

ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.IntegratedSecurity = true;
connectionInfo.ServerName = frmMainButton._initialParam.DBDataSource;
connectionInfo.DatabaseName = frmMainButton._initialParam.DBDataSource + @"\" + _mainTableName;
connectionInfo.UserID = "";
connectionInfo.Password = "";

Tables tables = doc.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
table.LogOnInfo.ConnectionInfo.DatabaseName = frmMainButton._initialParam.DBDataSource + @"\" + table.LogOnInfo.TableName.ToString() + ".DBF";
table.LogOnInfo.ConnectionInfo.ServerName = frmMainButton._initialParam.DBDataSource;
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}

crystalReportViewer.UseWaitCursor = true;
crystalReportViewer.ReportSource = doc;
crystalReportViewer.ParameterFieldInfo = paramFields;
crystalReportViewer.RefreshReport();
crystalReportViewer.UseWaitCursor = false;



Thank you :))
Sahira Zaman 14-Jul-13 4:36am
   
Hi Sushil, I solved the issue 1, but what about the parameters issue 2?
How should I be sending the parameters? I get that value is null :(

Cheers
Sushil Mate 14-Jul-13 8:49am
   
So you solved all your problems. great job.
I finally fixed the parameters issue by sending the correct values and description :)

Finally I got it working

Thanks a lot
   

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