Re: Is Any familar with Pro*C calls in Visual C++/MFC

From: Dietmar Leibecke <dleibeck_at_debis.com>
Date: 1998/04/14
Message-ID: <353372CB.C0B8B24A_at_debis.com>#1/1


Joerg Reiner wrote:

> Hello,
>
> how can I embed Pro*C commands in an C++ or more specific
> in an Visual C++ / MFC program. Is there any chance?
> Up till now i find no solution. Either with the CODE=CPP option nor
> PARSE=NONE or something.
> Where must I place the code or write a special "Connection"-Class.
>
> Any help is appreciated
>
> Joerg

This message has been written by Mark Tomlinson a few weeks ago. Hope it helps...

The following steps provide a guide to creating a very basic Dialog box based Pro*C application in Microsoft Visual C. This assumes you are familiar with both products...(This may have been done with 4.x rather than 5.x, but the steps would be very similar).

24 steps to a basic MSVC Pro*C application:


  1. File -> New -> Project Workspace
  2. MFC AppWizard (exe) and give it a name (for this example 'TEST')
  3. Type = Dialog based / Language = U.S. English
  4. Click Finish
  5. Click OK (when shown the project information)
  6. Once the project is created, click on the ResourceView tab
  7. Click on the Dialog sub-folder
  8. Click on IDD_TEST_DIALOG
  9. Add an edit field to the dialog using Controls editor
  10. Add a button to the dialog using Controls editor
  11. Press the Ctrl+W buttons
  12. Click the Message Maps tab in the MFC Class Wizard
  13. Select the CTESTDlg class in the class name drop down
  14. Click on IDC_BUTTON1 in the Object IDs
  15. Click on BN_CLICKED in the Messages list
  16. Click OK (when the Add Member Function dialog pops up)
  17. Click OK (dismiss the MFC Class Wizard)
  18. Open the TESTDLG.CPP file in the editor
  19. Locate the line: void CTESTDlg::OnButton1() -and- set the following code there:

extern"C"
{
#include "d:\orant\pro22\c\include\sqlca.h" }

EXEC SQL BEGIN DECLARE SECTION;
 VARCHAR v_loc[20];
 char* connstr = "scott/tiger_at_t:myserver:ORCL"; EXEC SQL END DECLARE SECTION; void CTESTDlg::OnButton1()
{
 // TODO: Add your control notification handler code here  EXEC SQL CONNECT :connstr;
 EXEC SQL SELECT loc INTO :v_loc FROM DEPT WHERE deptno = 40;  EXEC SQL COMMIT WORK RELEASE;  v_loc.arr[v_loc.len+1] = 0;

 SetDlgItemText(IDC_EDIT1,(char*)v_loc.arr); }

20) Save the modified TESTDLG.CPP to TESTDLG.PC
21) Precompile TESTDLG.PC to TESTDLG.CPP using the CODE=CPP option.
22) Add the following include to the top of the TESTDLG.CPP file:
(see BUG 346844)

#include "stdafx.h"

23) Ensure that SQLLIB18.LIB is included in the project. 24) Compile and link the program


--
Dietmar Leibecke
debis Systemhaus GmbH
----------------------------
Opinions are mine and do not
necessarily reflect those of
my employer
Received on Tue Apr 14 1998 - 00:00:00 CEST

Original text of this message