Trouble linking to SQL DB in VC++
-
Hi All, I'm new to these boards. You guys seem like a knowledgeable group of programmers, so let me throw out my first question: I'm enhancing a c++ MFC application that querys various databases and displays the info. I need to add a new query class for a brand new query. I went ahead and copied one of the previous queries and changed the variables and parameters, etc.. When I compile I get the following error: Error 1 error C2039: 'classCSetspQueryForTimeOverlap' : is not a member of 'CSetspQueryForTimeOverlap' c:\setspqueryfortimeoverlap.cpp 15 Because the class that it's talking about, classCSetspQueryForTimeOverlap is not something I've created, This seems to have something to do with dynamic linking. I have declared the header file CSetspQueryTimeOverlap.h: DECLARE_DYNAMIC(CSetspQueryTimeOverlap) and in the implementation file CSetspQueryTimeOverlap.cpp: IMPLEMENT_DYNAMIC(CSetspQueryForTimeOverlap, CBaseRecordset) Any help, suggestions, advice appreciated. Thanks.
-
Hi All, I'm new to these boards. You guys seem like a knowledgeable group of programmers, so let me throw out my first question: I'm enhancing a c++ MFC application that querys various databases and displays the info. I need to add a new query class for a brand new query. I went ahead and copied one of the previous queries and changed the variables and parameters, etc.. When I compile I get the following error: Error 1 error C2039: 'classCSetspQueryForTimeOverlap' : is not a member of 'CSetspQueryForTimeOverlap' c:\setspqueryfortimeoverlap.cpp 15 Because the class that it's talking about, classCSetspQueryForTimeOverlap is not something I've created, This seems to have something to do with dynamic linking. I have declared the header file CSetspQueryTimeOverlap.h: DECLARE_DYNAMIC(CSetspQueryTimeOverlap) and in the implementation file CSetspQueryTimeOverlap.cpp: IMPLEMENT_DYNAMIC(CSetspQueryForTimeOverlap, CBaseRecordset) Any help, suggestions, advice appreciated. Thanks.
DECLARE_DYNAMIC/IMPLEMENT_DYNAMIC have nothing to do with dynamic linking. These macros add members to CObject-derived classes so they provide runtime type information which is used by the MFC framework. Have you actually implemented the class or only used the macro? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
DECLARE_DYNAMIC/IMPLEMENT_DYNAMIC have nothing to do with dynamic linking. These macros add members to CObject-derived classes so they provide runtime type information which is used by the MFC framework. Have you actually implemented the class or only used the macro? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
ok, well ... that shows you what i know! thanks for your help, much appreciated. i'm still learning the lingo: i have "implemented the class" if that means that i created both a header and implementation file, and added them to the project. note that the error message points to the line directly before the IMPLEMENT_DYNAMIC statement in the implementation file. here is the text from the header file, for example: //////////////////////////////////////////////////////// #include "StdAfx.h" #include "SNU.h" #include "BaseRecordsetOdbc.h" #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // JF created to StartTime & EndTime validation class CSetspQueryForTimeOverlap : public CBaseRecordset { public: CSetspQueryForTimeOverlap(CDatabase* pDatabase = NULL); DECLARE_DYNAMIC(CSetspQueryTimeOverlap) // Field data long m_PaymentID; // Param data long m_paramClientIDParam; COleDateTime m_paramStartTimeParam; COleDateTime m_paramEndTimeParam; BOOL Run(long ClientID, COleDateTime StartTime, COleDateTime EndTime); // Overrides virtual CString GetDefaultSQL(); // Default SQL for Recordset virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support // Implementation #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; /////////////////////////////////////////////////////////// and here is the code from the implementation file: /////////////////////////////////////////////////////////// #include "StdAfx.h" #include "SetspQueryForTimeOverlap.h" #include "SNU.h" #include "BaseRecordsetOdbc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif IMPLEMENT_DYNAMIC(CSetspQueryForTimeOverlap, CBaseRecordset) CSetspQueryForTimeOverlap::CSetspQueryForTimeOverlap(CDatabase* pdb) : CBaseRecordset(gGetApp()->m_pDBPool, CDBConnectionPool::RecTypeSP) { // Field Init m_PaymentID = 0; m_nFields = 1; // Param Init m_paramClientIDParam = 0; m_paramStartTimeParam = COleDateTime(1972,1,22,0,0,0); // Initialize to "dummy value" - my birfday! JF m_paramEndTimeParam = COleDateTime(1972,1,22,0,0,0); m_nParams = 3; m_nDefaultType = snapshot; } CString CSetspQueryForTimeOverlap::GetDefaultSQL() { return _T("{CALL spQueryTimeOverlap (?,?,?)}"); } void CSetspQueryForTimeOverlap::DoFieldExchange(CFieldExchange* pFX) { // RFX field mapping pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Long(pFX, _T("[P
-
ok, well ... that shows you what i know! thanks for your help, much appreciated. i'm still learning the lingo: i have "implemented the class" if that means that i created both a header and implementation file, and added them to the project. note that the error message points to the line directly before the IMPLEMENT_DYNAMIC statement in the implementation file. here is the text from the header file, for example: //////////////////////////////////////////////////////// #include "StdAfx.h" #include "SNU.h" #include "BaseRecordsetOdbc.h" #if _MSC_VER >= 1000 #pragma once #endif // _MSC_VER >= 1000 // JF created to StartTime & EndTime validation class CSetspQueryForTimeOverlap : public CBaseRecordset { public: CSetspQueryForTimeOverlap(CDatabase* pDatabase = NULL); DECLARE_DYNAMIC(CSetspQueryTimeOverlap) // Field data long m_PaymentID; // Param data long m_paramClientIDParam; COleDateTime m_paramStartTimeParam; COleDateTime m_paramEndTimeParam; BOOL Run(long ClientID, COleDateTime StartTime, COleDateTime EndTime); // Overrides virtual CString GetDefaultSQL(); // Default SQL for Recordset virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support // Implementation #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; /////////////////////////////////////////////////////////// and here is the code from the implementation file: /////////////////////////////////////////////////////////// #include "StdAfx.h" #include "SetspQueryForTimeOverlap.h" #include "SNU.h" #include "BaseRecordsetOdbc.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif IMPLEMENT_DYNAMIC(CSetspQueryForTimeOverlap, CBaseRecordset) CSetspQueryForTimeOverlap::CSetspQueryForTimeOverlap(CDatabase* pdb) : CBaseRecordset(gGetApp()->m_pDBPool, CDBConnectionPool::RecTypeSP) { // Field Init m_PaymentID = 0; m_nFields = 1; // Param Init m_paramClientIDParam = 0; m_paramStartTimeParam = COleDateTime(1972,1,22,0,0,0); // Initialize to "dummy value" - my birfday! JF m_paramEndTimeParam = COleDateTime(1972,1,22,0,0,0); m_nParams = 3; m_nDefaultType = snapshot; } CString CSetspQueryForTimeOverlap::GetDefaultSQL() { return _T("{CALL spQueryTimeOverlap (?,?,?)}"); } void CSetspQueryForTimeOverlap::DoFieldExchange(CFieldExchange* pFX) { // RFX field mapping pFX->SetFieldType(CFieldExchange::outputColumn); RFX_Long(pFX, _T("[P
Thanks for posting the code - You've implemented the class :) I'm not seeing what would cause the error but I'll keep looking at it. Is there a typo somewhere? Class name spelled wrong or one of the letters wrong case? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
-
Thanks for posting the code - You've implemented the class :) I'm not seeing what would cause the error but I'll keep looking at it. Is there a typo somewhere? Class name spelled wrong or one of the letters wrong case? Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
arrrrrrgghhh! yes, there was a spelling error in the DECLARE_DYNAMIC statement (missing "For" in the class name.) WOW, do I feel like an idiot! ok, are there any tricks experienced programmers use to prevent stuff like that before making embarrassing posts on CodeProject? and thanks again.
-
arrrrrrgghhh! yes, there was a spelling error in the DECLARE_DYNAMIC statement (missing "For" in the class name.) WOW, do I feel like an idiot! ok, are there any tricks experienced programmers use to prevent stuff like that before making embarrassing posts on CodeProject? and thanks again.
:-D I don't think it's embarrassing. Well maybe a little haha but I think first you'll get used to the error message and know it's something like that. Asking someone else to look when I'm stumped on something often helps. Sometimes someone else will see something right away that I've spent much time looking for. Of course I was no help to you on this one - I didn't see it :) Have fun! Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder