HELP ME!! ODBC access from dialog?? 
Author Message
 HELP ME!! ODBC access from dialog??

I have established a propertysheet inside a formview.
There is no problems accessing the odbc direct from the formview, but
inside the propertypage within the sheet, how do I access the data??

Please outline the process or give an address where I can find
instruction on accessing odbc data from a dialogderived class.

I have tried to add a 'Foreign variable': m_pSet referring to the
'foreign
class' representing the Set.
Automatic code is generated for the 'DoDataExchange' functionality, but
when
I check the variable
it is a null pointer!! - how is this initialised!?????

Code:

IMPLEMENT_DYNCREATE(CMyPage1, CPropertyPage)

CMyPage1::CMyPage1() : CPropertyPage(CMyPage1::IDD)
{
 file://{{AFX_DATA_INIT(CMyPage1)
 m_Set = NULL;
 file://}}AFX_DATA_INIT

Quote:
}

CMyPage1::~CMyPage1()
{

Quote:
}

void CMyPage1::DoDataExchange(CDataExchange* pDX)
{ CModitab10View* Viewdata;
 CPropertyPage::DoDataExchange(pDX);
 if (m_Set==NULL) {MessageBox("NULLPointer");} else
{MessageBox("NotNull");}
 //{{AFX_DATA_MAP(CMyPage1)
 DDX_FieldText(pDX, IDC_EDIT1, m_Set->m_Capacity, m_Set);
 DDX_FieldText(pDX, IDC_EDIT3, m_Set->m_InstructorID, m_Set);
 //}}AFX_DATA_MAP

Quote:
}

BEGIN_MESSAGE_MAP(CMyPage1, CPropertyPage)
 //{{AFX_MSG_MAP(CMyPage1)
  // NOTE: the ClassWizard will add message map macros here
 //}}AFX_MSG_MAP
END_MESSAGE_MAP()

Hope somone outthere can guide me - Thanks in advance



Sat, 02 Mar 2002 03:00:00 GMT  
 HELP ME!! ODBC access from dialog??
Oh dear !!

You need to at least allocate a new recordset on the heap a good place to do
this would be in your
overriden ONInitDialog:

CMyPage1::OnInitDialog()
{
    m_pSet = new CWhatIsYourDerivedClassSet;
    if ( ! m_pSet->Open() )
        ::TRACE("CMyPage1::OnInitDialog failed to open recordset");

Quote:
}

If you wanted to use the FormView's recordset then you could pass the
FormViews recordset into
a new version of the constructor and fire away ( no changes necessary ):

CMyPage1::CMyPage1(CRecordset *pSet) : CPropertyPage(CMyPage1::IDD)
{
file://{{AFX_DATA_INIT(CMyPage1)
m_pSet = pSet;
file://}}AFX_DATA_INIT

Quote:
}

CMyPage1::CMyPage1(
Quote:

>I have established a propertysheet inside a formview.
>There is no problems accessing the odbc direct from the formview, but
>inside the propertypage within the sheet, how do I access the data??

>Please outline the process or give an address where I can find
>instruction on accessing odbc data from a dialogderived class.

>I have tried to add a 'Foreign variable': m_pSet referring to the
>'foreign
>class' representing the Set.
>Automatic code is generated for the 'DoDataExchange' functionality, but
>when
>I check the variable
>it is a null pointer!! - how is this initialised!?????

>Code:

>IMPLEMENT_DYNCREATE(CMyPage1, CPropertyPage)

>CMyPage1::CMyPage1() : CPropertyPage(CMyPage1::IDD)
>{
> file://{{AFX_DATA_INIT(CMyPage1)
> m_Set = NULL;
> file://}}AFX_DATA_INIT
>}

>CMyPage1::~CMyPage1()
>{
>}

>void CMyPage1::DoDataExchange(CDataExchange* pDX)
>{ CModitab10View* Viewdata;
> CPropertyPage::DoDataExchange(pDX);
> if (m_Set==NULL) {MessageBox("NULLPointer");} else
>{MessageBox("NotNull");}
> //{{AFX_DATA_MAP(CMyPage1)
> DDX_FieldText(pDX, IDC_EDIT1, m_Set->m_Capacity, m_Set);
> DDX_FieldText(pDX, IDC_EDIT3, m_Set->m_InstructorID, m_Set);
> //}}AFX_DATA_MAP
>}

>BEGIN_MESSAGE_MAP(CMyPage1, CPropertyPage)
> //{{AFX_MSG_MAP(CMyPage1)

 // NOTE: the ClassWizard will add message map macros here

- Show quoted text -

Quote:
> //}}AFX_MSG_MAP
>END_MESSAGE_MAP()

>Hope somone outthere can guide me - Thanks in advance




Thu, 07 Mar 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help: Using MFC ODBC classes to access SQL BLOBs

2. ODBC Access driver on peer-to-peer help

3. HELP!ODBC API call SQLFetchScroll returns Access violation with ODBCCR32.dll

4. HELP!!!! SQLDriverConnect ODBC API Access Violations

5. [Fwd: HELP!!!! SQLDriverConnect ODBC API Access Violations ]

6. Strange ODBC errors using DAO to access linked tables in Access .MDB

7. Accessing access via MFC Database classes and ODBC

8. Accessing an Ms Access 2000 Query using VC++, via ODBC

9. Accessing access via MFC Database classes and ODBC

10. Accessing access via MFC Database classes and ODBC

11. Need Help, Please - CRecordView (ODBC) and Pop-up Dialog

12. HELP: ODBC connection dialog box

 

 
Powered by phpBB® Forum Software