Crystal Reports: SQL Server & MS VC++ 6.0 
Author Message
 Crystal Reports: SQL Server & MS VC++ 6.0

Hello everyone!

I am having a problem getting a Crystal Report to fire up.

The problem is simply when I execute crJob->Start(); the report does
not load and I get an error message saying: "Can not open SQL Server".

The ctor for CCrystalReport finds the report and sets up the logon
parameters.  I used to perform a Crystal Report logon there but no
longer do so.  In fact when I did I was having the same problem but
eventually solved the problem (casing on one of the parameters).

I've checked the report for any thing that might be mucking things up
but everything looks good.

Below is the code I am using to run this report.

Thanks for any & all help!

bool CCrystalReport::RunReport(const CString& sccsmcno)
{
        bool return_value = true;
                //redo connection.

        CRPELogOnInfo LogOnInfo(m_strDSN, "databasename",
m_strLogonName, m_strPassword);

        if(!CRPEngine::GetEngine()->LogOnServer("p2sodbc.dll",
&LogOnInfo))
        {
                CString strerror(CRPEngine::GetEngine()->GetErrorText
());
                AfxMessageBox(strerror);
                ValidObject = false;
        }

        if(ValidObject)
        {
                CRPEJob* crJob = CRPEngine::GetEngine()->OpenJob
(m_strReportName);
                crJob->EnableProgressDialog(FALSE);

                CRPEParameterFieldInfo param;

                if(m_boolScreenPreview)
                {
                        crJob->OutputToWindow("Report", CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, WS_POPUPWINDOW |
WS_OVERLAPPEDWINDOW, (CWnd*) NULL);
                }
                else
                {
                        crJob->OutputToPrinter(m_intCopies);
                        crJob->SelectPrinter("","","");
                }

                //Set user name.
                CString name(m_strLogonName);
//convention is that logon names start with A_ I don't want that in the
//report.
                name.TrimRight("A_");
                crJob->SetFormula("user", name);

//The one parameter for this report is 2 char field company number.
                crJob->GetNthParameterField(0, &param);
                param.m_CurrentValueSet = TRUE;
                lstrcpy(param.m_CurrentValue, (sccsmcno.Left(2)));
                crJob->SetNthParameterField(0, &param);

                HWND h;

                AfxMessageBox("Report about to start.");
                BOOL job_result = crJob->Start();

                if( job_result )
                {
//We never get here.
                        h = crJob->GetWindowHandle();
                        AfxMessageBox("Report finsihed.");
                        crJob->Close();
                }
                else
                {
//We always wind up here.
                        AfxMessageBox(crJob->GetErrorText());
                        crJob->Close();
                }

        }
        else
        {
                return_value = false;
        }

        return return_value;

Quote:
}

--
From:  Mark Framness
http://www.*-*-*.com/ ~farmer/index.html
All standard disclaimers apply anyone who say otherwise is itching for a

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Sun, 21 Apr 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Problem linking with Crystal Reports and MS VC++ 6.0 Professional

2. When working with Crystal Reports how to get SQL query from a sub-report

3. Crystal Reports 7.0 MFC bug (VC++ 6.0 / CRPE / Access / ODBC)

4. Crystal Reports 7.0 MFC bug (VC++ 6.0 / CRPE / Access / ODBC)

5. Perform SQL statement in VC++ against MS SQL Server 7.0

6. Crystal Reports - in VC (anyone done it?) reporting

7. Using VC++ 6.0 as an automation client to view and print reports from MS Access 97

8. OCX & MS SQL Server

9. Update SQL query in Crystal report

10. Update SQL query in Crystal report

11. Show SQL Query from a Crystal Report

12. Invoking MS SQL Server Procedures from VC++

 

 
Powered by phpBB® Forum Software