PRB: MFC AppWizard Does Not Show Oracle Synonyms with Microsoft ODBC Driver (296091)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++, 32-bit Editions 4.2
  • Microsoft Visual C++, 32-bit Editions 5.0
  • Microsoft Visual C++, 32-bit Editions 6.0
  • Microsoft Data Access Components 1.5
  • Microsoft Data Access Components 2.0
  • Microsoft Data Access Components 2.1
  • Microsoft Data Access Components 2.5
  • Microsoft Data Access Components 2.6

This article was previously published under Q296091

SYMPTOMS

When you create a Visual C++ Microsoft Foundation Classes (MFC) AppWizard EXE or DLL with database support, if you select an Oracle data source name (DSN) that is associated with the Microsoft ODBC Driver for Oracle, AppWizard doesn't list the local and public Oracle synonyms in the Select Database Tables window.

RESOLUTION

You can work around this problem in the following ways:
  • You can create and use Oracle views instead of Oracle synonyms.
  • If you are using Visual C++, you can use the Microsoft OLE DB Provider for Oracle, instead of the Microsoft ODBC Driver for Oracle, to obtain local synonyms and tables associated with public synonyms.
Note The workaround that uses the Microsoft OLE DB Provider for Oracle does not apply to Microsoft Visual C++ .NET 2002 or to Microsoft Visual C++ .NET 2003.

For examples of these workarounds, see the "More Information" section.

STATUS

This behavior is by design.

MORE INFORMATION

Unlike Microsoft Access and the MFC AppWizard with the Microsoft OLEDB Provider for Oracle, the MFC AppWizard connecting to an Oracle database using the Microsoft ODBC Driver for Oracle doesn't list local (created in the current schema) and public synonyms.

Steps to Reproduce Behavior

Visual C++ versions 6.0 and earlier

  1. Create a table in schema "SCOTT":
    CREATE TABLE scott_test(col1 INT)
    					
  2. Create a public synonym on this table and give everyone "SELECT" permission:
    CREATE PUBLIC SYNONYM scott_test_syn FOR scott_test
    Grant SELECT on scott_test_syn TO PUBLIC
    					
  3. Start Visual C++. On the File menu, click New.
  4. Click the Projects tab, select MFC AppWizard (exe), type the project name, and then click OK.
  5. Accept the defaults and then click Next.
  6. Select Database view without file support or Database view with file support, and then click the Data Source button.
  7. Select an Oracle ODBC DSN associated with the Microsoft ODBC Drvier for Oracle and click OK.
  8. Enter the user name (schema other than SCOTT to perform this test) and password. Click OK.
  9. In the Select Database Tables window, the public synonym "scott_test_syn" is not listed.

Visual C++ .NET

  1. Create a table in schema "SCOTT":
    CREATE TABLE scott_test(col1 INT)
    					
  2. Create a public synonym on this table and give everyone "SELECT" permission:
    CREATE PUBLIC SYNONYM scott_test_syn FOR scott_test
    Grant SELECT on scott_test_syn TO PUBLIC
    					
  3. Start Visual Studio .NET. On the File menu, point to New, and then click Project.
  4. Under Project Types, choose Visual C++ Projects, and then select MFC Application under Templates.
  5. Give the project a name and then click OK. The MFC Application Wizard starts.
  6. Click Database Support, and then select either Database view without file support or Database view with file support. If you choose Database view without file support, you receive the following message:
    Selecting a database view without file support forces your project to use the Single Document Interface.
    To keep this setting, click Yes. If you click No, the setting defaults to Database view with file support.

  7. Under Client Type, select ODBC, and then click Datasource.
  8. Select an Oracle ODBC DSN that is associated with the Microsoft ODBC Drvier for Oracle, and then click OK.
  9. Type the user name (schema other than SCOTT to perform this test) and password. Click OK.
  10. In the Select Data Object window, the public synonym "scott_test_syn" is not listed.
Using these examples, you can work around the problem in the following ways:
  • If you select the Microsoft OLE DB Provider for Oracle (instead of the Microsoft ODBC Driver for Oracle), the MFC App Wizard will list "scott_test", which is the table associated with the public synonym "scott_test_syn".
  • You can also create a view on the table asssociated with the public synonym in the schema you want to connect to using MFC AppWizard:
    CREATE VIEW scott_test_view AS
    SELECT * FROM SCOTT.scott_test;
    						
    You will then see "scott_test_view" in the list of tables.

Modification Type:MajorLast Reviewed:1/23/2004
Keywords:kbDriver kbOracle kbprb KB296091 kbAudDeveloper