cancel
Showing results for 
Search instead for 
Did you mean: 

CRVS2010 Beta - Database logon failed

Former Member
0 Kudos

The VS 2010 project I am working on was working, but it apparently was only working when I set the RecordSelectionFormula to the data of the saved report. I updated the report to not save the data and now I get a database logon failed error whenever I try to run the report. It would seem that it ignores the input parameters i set as well as the RecordSelectionFormula that I set. Am I missing a step?

Here is what my project does


            ReportDocument crDoc = new ReportDocument();
            String rptPath = @"c:\PackingSlip.rpt";
            crDoc.Load( rptPath );
            crDoc.SetDatabaseLogon("sms_user", "user5pwd", "ts-sms01", "shipmgmt");
            String whereClause = "{ld_mstr.ldm_ord} = '145916' AND {ld_mstr.ldm_nbr} = '24936'";
            crDoc.RecordSelectionFormula = whereClause;
            Object sfVal = new Object();
            sfVal = "C37-2";
            Object prncases = new Object();
            prncases = false;
            crDoc.SetParameterValue("shipFrom", sfVal);
            crDoc.SetParameterValue("prnCases", prncases);
            crDoc.PrintOptions.PrinterName = @"\\wc-printserver\wccsr";
            try
            {
                crDoc.PrintToPrinter(1, false, 0, 0);
            }
            catch (LogOnException errMsg)
            {
                MessageBox.Show("ERROR: " + errMsg.Message.ToString());
            }
            crDoc.Dispose();

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello,

Start by testing those values in the Designer first to verify the format is correct. And then rather than print try previewing, if anything is missing a pop-up should show up to fill in the missing info.

Also, to determine if it is a database log on issue don't set the filters, remove the parameter also.

Next is you should update your references and add RAS. Then use the ClientDocument like so:

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.ReportDefModel;

using CrystalDecisions.ReportAppServer.DataSetConversion;

using CrystalDecisions.ReportAppServer.DataDefModel;

...

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

ISCDReportClientDocument rptClientDoc;

Open report:

rptClientDoc = new ReportClientDocumentClass();

openFileDialog.Filter = "Crystal Reports (.rpt)|.rpt";

rpt.Load(rptName.ToString());

rptClientDoc = rpt.ReportClientDocument;

Set log on info:

rptClientDoc.DatabaseController.LogonEx("dwcb12003", "CrystalReport_DB", "sa", "password");

Thank you

Don

0 Kudos

And then...

Next is to not use the PrintToPrinter function but use the PrintController:

private void button1_Click(object sender, System.EventArgs e)

{

System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptionsClass();

CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions newOpts = new PrintOptionsClass();

pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.Text;

rasPROpts.PrinterName = cboCurrentPrinters.Text;

rasPROpts.PaperSize = (CrPaperSizeEnum)

pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind;

rasPROpts.PaperSource = (CrPaperSourceEnum)

pDoc.PrinterSettings.PaperSources[cboDefaultPaperTrays.SelectedIndex].Kind;

rasPROpts.JobTitle = "MYPrintJob";

rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

//MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information );

}

Thanks again

Don

Former Member
0 Kudos

Still getting the same error about database logon. I have put my new code below. Where do I set the RecordSelectionFormula? As part of the ReportDocument or as part of the ISDCREportClientDocument?


CrystalDecisions.CrystalReports.Engine.ReportDocument crDoc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ISCDReportClientDocument rptClientDoc = new ReportClientDocument();
            PrintReportOptions crPrintOpts = new PrintReportOptions();
            
            String rptPath = @"c:\PackingSlip.rpt";
            crDoc.Load( rptPath );
            Object sfVal = new Object();
            sfVal = "C37-2";
            Object prncases = new Object();
            prncases = false;
            crDoc.SetParameterValue("shipFrom", sfVal);
            crDoc.SetParameterValue("prnCases", prncases);
            String whereClause = "{ld_mstr.ldm_ord} = '145916' AND {ld_mstr.ldm_nbr} = '24936'";
            crDoc.RecordSelectionFormula = whereClause;
            
            rptClientDoc = crDoc.ReportClientDocument;
            rptClientDoc.DatabaseController.LogonEx( "ts-sms01", "shipmgmt", "sms_user", "user5pwd" );

            crPrintOpts.PrinterName = @"\\wc-printserver\wccsr";
            crPrintOpts.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;
            crPrintOpts.JobTitle = @"Packing Slip Print";
                                    
            try
            {
                rptClientDoc.PrintOutputController.PrintReport(crPrintOpts);
                //crDoc.PrintToPrinter(1, false, 0, 0);
            }
            catch (LogOnException errMsg)
            {
                MessageBox.Show("ERROR: " + errMsg.Message.ToString());
            }
            crDoc.Dispose();

0 Kudos

Hello,

As suggested, comment out everything and then test just the connection methods.

Also, try some basic samples for more info on using various connection methods. You can get the samples from these links:

Root Page

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsHome

Enterprise Samples (including managed and unmanaged ras)

http://wiki.sdn.sap.com/wiki/display/BOBJ/BusinessObjectsSDKSampleApplications

Non-Enterprise Samples

http://wiki.sdn.sap.com/wiki/display/BOBJ/CrystalReportsSDKSampleApplications

Exporting Samples (RAS)

http://wiki.sdn.sap.com/wiki/display/BOBJ/NETRASSDK+Samples#NETRASSDKSamples-Exporting%2FPrinting

Thanks again

Don

Former Member
0 Kudos

I tried what you suggested as well as looking through the examples you linked to, but still no luck. The failure occurs when I make the call to the Print method. The login does not have issues nor do any of the other calls. It is when the print out occurs. What else can I try? As I said, I made updates similar to the examples and no improvements.

0 Kudos

Try a report with saved data then it doesn't need to refresh or hit the DB. If it doesn't have saved data then it must connect to the DB and the error won't show up until you try to export.

Former Member
0 Kudos

When I run the report with saved data, the report prints. If I add in the Record Selection Formula for the saved data, it prints. If I change it to another formula that works in developer, it fails to print and I get the logon error. Why does it fail on the print method when a different record selection formula is given? Again - it only prints the saved data version.

0 Kudos

Hello,

It fails because what you changed requires hitting the database again but your log on info is not correct. So as suggested, remove everything and first debug why your database connection is failing.

If you tell me what DB and which driver you are using I can test and verify the code to use.

Thank you

Don

Former Member
0 Kudos

I am connecting to a Progress DB using their specified driver (PGOE1022.dll).

So the setDatabaseLogon only sets the information, it is not actually making a connection, correct? The information i am giving it is correct and i can login using that information.

Former Member
0 Kudos

Anyone have more input on this? the login information is correct. I have gone through all of the example methods of doing this and cannot get it to work correctly. Am I missing a step somewhere? Why does this keep failing? I need to get this working before our project can move forward.

Former Member
0 Kudos

Still at a loss on this one. Cannot get this to function correctly. Any other suggestions for me to try? Please let me know, thank you.

0 Kudos

Hello,

Try simplifying your report, one table, one field and no parameters and then start adding parts in.

This app may help also, it will generate the logon info required for your report. Open it up and verify it uses the 14.0 versions and then compile and run it against your report.

Thank you

Don

Former Member
0 Kudos

I have tried this again. I have a simple report - 1 table. It displays 2 fields and uses 1 field as the record selection formula. It seems to work when i use the .logon method, but not he .LogonEx method. I need to use the latter to tell it which database and on what server. I get the Database Logon Failed error message when running it from .LogonEx but it prints as expected when using .Logon. why?

Former Member
0 Kudos

Also - the zip file was empty when I downloaded it.

0 Kudos

Try this for printing:

private void button1_Click(object sender, System.EventArgs e)

{

System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument();

CrystalDecisions.ReportAppServer.Controllers.PrintReportOptions rasPROpts = new CrystalDecisions.ReportAppServer.Controllers.PrintReportOptionsClass();

CrystalDecisions.ReportAppServer.ReportDefModel.PrintOptions newOpts = new PrintOptionsClass();

pDoc.PrinterSettings.PrinterName = cboCurrentPrinters.Text;

rasPROpts.PrinterName = cboCurrentPrinters.Text;

rasPROpts.PaperSize = (CrPaperSizeEnum)

pDoc.PrinterSettings.PaperSizes[cboCurrentPaperSizes.SelectedIndex].Kind;

//rasPROpts.PaperSource = (CrPaperSourceEnum)pDoc.PrinterSettings.PaperSources[cboCurrentPaperTrays.SelectedIndex].Kind;

rasPROpts.PaperSource = (CrPaperSourceEnum)

pDoc.PrinterSettings.PaperSources[cboDefaultPaperTrays.SelectedIndex].Kind;

rasPROpts.JobTitle = "MYPrintJob";

rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

MessageBox.Show("Printing report.", "RAS", MessageBoxButtons.OK,MessageBoxIcon.Information );

}

Former Member
0 Kudos

I don't see where you are telling this what report to print or what database to connect to. Also, you use rptClientDoc at the bottom of this to print but didn't define it up above. Is this in addition to what i have currently? If so, what does it do, as the new variables you define don't appear to have any effect on the printing of it, as I user PrintReportOptions currently. Let me know please, thanks.

0 Kudos

Hello,

I'm not putting it all in one note. Report Client Doc is in the database code I put in a few posts ago. but if you need a reference then:

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using CrystalDecisions.CrystalReports.Engine;

using CrystalDecisions.Shared;

using CrystalDecisions.ReportAppServer.ClientDoc;

using CrystalDecisions.ReportAppServer.Controllers;

using CrystalDecisions.ReportAppServer.ReportDefModel;

using System.Data.OleDb;

using CrystalDecisions.ReportAppServer.DataSetConversion;

using CrystalDecisions.ReportAppServer.DataDefModel;

...

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

ISCDReportClientDocument rptClientDoc;

...

Open using the file Dialog:

private void btnOpenReport_Click(object sender, System.EventArgs e)

{

rptClientDoc = new ReportClientDocumentClass();

openFileDialog.Filter = "Crystal Reports (.rpt)|.rpt";

if (openFileDialog.ShowDialog() == DialogResult.OK)

{

btnOpenReport.Enabled = false;

btnSaveRptAs.Enabled = false;

object rptName = openFileDialog.FileName;

rpt.Load(rptName.ToString());

rptClientDoc = rpt.ReportClientDocument;

MessageBox.Show("Report opened.","RAS",MessageBoxButtons.OK,MessageBoxIcon.Information );

btnOpenReport.Enabled = true;

btnSaveRptAs.Enabled = true;

}

}

Then set the log on info and then print the report.

Thank you

Don

Former Member
0 Kudos

Where does the record select formula get set? here is how I did it, but it says Database Logon Failed everytime I run it.


private void btnPrint_Click(object sender, EventArgs e)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ISCDReportClientDocument rptClientDoc;
            PrintReportOptions rasPROpts = new PrintReportOptionsClass();

            //rptClientDoc = new ReportDocumentClass();

            rpt.Load( "C:\\PackingSlip.rpt" );
            rpt.RecordSelectionFormula = @"{ld_mstr.ldm_nbr} = '13994'";
            rptClientDoc = rpt.ReportClientDocument;

            rptClientDoc.DatabaseController.LogonEx( "localhost", "shipmgmt", "sms_user", "user5pwd" );
            
            rasPROpts.PrinterName = @"\\wc-printserver\WCCSSR";
            
            rasPROpts.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;
            rasPROpts.JobTitle = "MYPrintJob";
            
            try
            {
                rptClientDoc.PrintOutputController.PrintReport(rasPROpts);
            }
            catch
            { }
            finally
            {
                rptClientDoc.Close();
                rpt.Close();
            }
        }

0 Kudos

Set the record selection formula after you set the log on info. Setting it first uses the original logon info and it gets cleared once you set the log on info to another source.

It does this because the reports record selection formula may change with a new data source.

Thank you

Don

Former Member
0 Kudos

But I don't see record select formula anywhere under rptClientDoc as being able to be set like I can with rpt.RecordSelectFormula. What is the correct syntax for that?

Former Member
0 Kudos

OK - I have broken this down to the simplest possible way of doing this. Below is what I am doing currently. This will print every time, no Database Logon error. However, it will only print the actual data if the report file was saved with that data. I.E. I tried 3 different numbers that all return data with Crystal Reports Designer, but when it prints, it prints a blank page, as if it is ignoring the record select formula. Why?

private void btnPrint_Click(object sender, EventArgs e)

{

ReportDocument rpt = new ReportDocument();

rpt.Load(@"c:\Test.rpt");

rpt.SetDatabaseLogon("sms_user", "user5pwd", "localhost", "shipmgmt");

rpt.RecordSelectionFormula = @"{ld_mstr1.ldm_nbr} = '30646'";

rpt.PrintOptions.PrinterName = @"
wc-printserver\WCCSR";

try

{

rpt.PrintToPrinter(1, false, 0, 0);

}

catch( Exception ex )

{

MessageBox.Show("ERROR: " + ex.Message);

}

finally

{

rpt.Dispose();

}

}

0 Kudos

But you went back to using the engine.... So your database logon is still failing.

And NEVER use "localhost" as your Server name. It's a reserved name for the system only. Use the actual server name or IP address. Try your code again but use the server name.

All that you should of had to do is make changes to your RAS code to this:

private void btnPrint_Click(object sender, EventArgs e)

{

CrystalDecisions.CrystalReports.Engine.ReportDocument rpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

ISCDReportClientDocument rptClientDoc;

PrintReportOptions rasPROpts = new PrintReportOptionsClass();

//rptClientDoc = new ReportDocumentClass();

rpt.Load( "C:
PackingSlip.rpt" );

rptClientDoc = rpt.ReportClientDocument;

rptClientDoc.DatabaseController.LogonEx( "REAL SERVER NAME HERE", "shipmgmt", "sms_user", "user5pwd" );

//moved this line

rpt.RecordSelectionFormula = @"{ld_mstr.ldm_nbr} = '13994'";

rasPROpts.PrinterName = @"
wc-printserver\WCCSSR";

rasPROpts.PrinterDuplex = CrPrinterDuplexEnum.crPrinterDuplexSimplex;

rasPROpts.JobTitle = "MYPrintJob";

try

{

rptClientDoc.PrintOutputController.PrintReport(rasPROpts);

}

catch

{ }

finally

{

rptClientDoc.Close();

rpt.Close();

}

}

Also note that the Engine is used to edit the record selection formula....

Edited by: Don Williams on Jul 23, 2010 6:58 AM

Edited by: Don Williams on Jul 23, 2010 7:11 AM

Former Member
0 Kudos

Don - yes I did "go back" to using the Engine only, as that is, so far, the only way I do not get a logon issue. I did as you said in your last message and I still have the same issue. It prints blank pages for everything except the saved data version of the report. It is not using my Record Select Formula for some reason. Why?

Also, what is wrong with the Engine only approach? that is what we used in our old software and had no issues with it. We are not trying to do anything fancy other than print a report in the background by setting the printer, report, and record selection formula. How can I achieve this?

0 Kudos

Nothing wrong with using the engine only, it's just limited in it's abilities. If it works for you then continue using it only. PrintToPrinter is not very robust though so you may have to switch to the PrintDocumentController in RAS.

You'll have to debug the database connection problems using SQL tools or ODBC tracing. Try a different type of connection to see if that resolves the issue...

I'll see if I can get a crlogger.dll version for this version. It logs all database API's and may help.

Just had a look and we do ship it with the beta.... Go into System Properties and Environment variables and add these:

LOGGING_DIR = c:\logging

LOGGING_ENABLED_ASSERT = 1

LOGGING_ENABLED_RUNTIME = 30

Create a c:\logging folder. Close your app and then re-open it and then run the app again. Look through the log and you should see the same error message with more info.

Thank you

Don

Edited by: Don Williams on Jul 23, 2010 8:50 AM

Answers (0)