HELP! Whats wrong with this code?VC1.52 
Author Message
 HELP! Whats wrong with this code?VC1.52

Hello :) Im using VC1.52 for a little app.
Ive just created a dialog, which has edit controls mapped to the ODBC
database(Crecordset object), via foreign variables m_pSet.> ect. but my
dialog is not showing up at all.

So I thought I would try and catch the DBexception.  but "try" is now
allowed in VC1.52 only "TRY" (does this make a difference?), and the
error when compiled is:
**** error C2143: syntax error : missing ';' before 'catch' ****

How should I initialize the dialog so it pops up with the assigned
recordset? What am I doing wrong?  Without the 3 edit controls, just as
a dialog box, it works fine... so it must be the database elements.

My code:

void CCalendarApp::OnShiftShiftdata()
{
        CShiftdlg shiftdlg;
        shiftdlg.DoModal;         // Create instance of dialog class

Quote:
}

BOOL CShiftdlg::OnInitDialog()
{
        TRY {
        CtblShift* m_pSet;  // Create an instance of Recordset CtblShift
        m_pSet->Open();     // Open Recordset
        UpdateData(FALSE);
        }
        catch(CDBException *e) {
          AfxMessageBox(CString("Cannot Open Database.\n")
          + e->m_strError, MB_ICONSTOP);
          throw;
        )
        CDialog::OnInitDialog();
        return TRUE;  // return TRUE  unless you set the focus to a control
Quote:
}



Wed, 15 Sep 1999 03:00:00 GMT  
 HELP! Whats wrong with this code?VC1.52

Quote:
> So I thought I would try and catch the DBexception.  but "try" is now
> allowed in VC1.52 only "TRY" (does this make a difference?), and the
> error when compiled is:
> **** error C2143: syntax error : missing ';' before 'catch' ****

"Chapter 16 Exceptions" of the "Class Library User's Guide"
of the Documentation of VC 1.5 will answer your question.

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

The following instructions and examples will show you how to catch
exceptions.
T      To catch exceptions
     Use the TRY macro to set up a TRY block. Execute any program statements
that might throw an exception within a TRY block.
        Use the CATCH macro to set up a CATCH block. Place exception handling code
in a CATCH block. The code in the CATCH block is executed only if the code
within the TRY block throws an exception of the type specified in the CATCH
statement.
        The following skeleton shows how TRY and CATCH blocks are normally
arranged:

// Normal program statements
...

TRY
{
        // Execute some code that might throw an exception.

Quote:
}

CATCH( CException, e )
{
        // Handle the exception here.
        // "e" contains information about the exception
Quote:
}

END_CATCH

// Other normal program statements
...

Note  The END_CATCH macro marks the end of the CATCH blocks.

        The CATCH macro takes an exception-type parameter, allowing you to
selectively handle different types of exceptions with sequential CATCH and
AND_CATCH blocks as listed below:

TRY
{
        // Execute some code that might throw an exception.

Quote:
}

CATCH( CMemoryException, e )
{
        // Handle the out-of-memory exception here.
Quote:
}

AND_CATCH( CFileException, e )
{
        // Handle the file exceptions here.
Quote:
}

AND_CATCH( CException, e )
{
        // Handle all other types of exceptions here.
Quote:
}

END_CATCH


Wed, 15 Sep 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. VC1.52!!Whats wrong with this??

2. Help - How to access MS-ACCess from VC1.52

3. Help porting VC1.52 DLL to VC2.2 DLL

4. (Urgent, plz help)Problem getting app pointer in VC1.52 (16bit)

5. Help: CRecordset using Oracle7 and VC1.52

6. Problem with vc1.52, dos window in win95 and graphics program

7. ldllcew.lib - converting VC1.52 to VC5

8. VC1.52 and Win95

9. VC1.52 Setup Install Program

10. Tabbing using VC1.52

11. VC1.52 Compiler optimisation problem

12. OCX Control in a VC1.52??

 

 
Powered by phpBB® Forum Software