ODBC problem updating from Visual Studio 2005 to 2012
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ODBC problem updating from Visual Studio 2005 to 2012

  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Question ODBC problem updating from Visual Studio 2005 to 2012

    I've go a set of large applications that were developed in Visual Studio 2005 and were working fine until I tried to do maintenance in VS 2012. At the heart of the problem is the open code::
    Code:
    	// The DBQ is the path and file name (fully qualified)
    	// The driver, inside the {} is magic for the exact driver name
    	//   which can be obtained from the ODBC administrator
    	// The UID is also available from the ODBC administrator
    	csBuffer = "ODBC;DBQ=";
    	csBuffer += m_csDatabasePath;
    	csBuffer += ";Driver={Microsoft Access Driver (*.mdb)};UID=admin";
    
    	m_pTestDatabase = new CDatabase;
    
    	TRY
    	{
    		//m_pTestDatabase->Open(NULL, FALSE, FALSE, (const char*)csBuffer);
    		BOOL bSuccess = m_pTestDatabase->OpenEx((const char*)csBuffer);
    		TRACE("OpenEx(%s) returned %s\n", csBuffer, bSuccess ? "true" : "false");
    	}
    	CATCH(CDBException, except)
    	{
    		csBuffer += "\nODBC ";
    		csBuffer += except->m_strError;
    		EndWaitCursor();
    		AfxMessageBox(csBuffer, MB_OK | MB_ICONSTOP);
    		delete m_pTestDatabase;
    		m_pTestDatabase = NULL;
    		return true;
    	}
    	END_CATCH;
    and::
    		// default options permit read, write, and append
    		m_pTblPlot->Open(CRecordset::snapshot, NULL, CRecordset::none);
    		if( !m_pTblPlot->CanUpdate() )
    		{
    			AfxMessageBox("SS Plot Specification database cannot be updated.", MB_OK | MB_ICONSTOP);
    		}
    If I proceed I find that I can read the record set but can not update it. I've got Access 2007 installed on my computer. Any suggestions?

  2. #2
    Join Date
    Feb 2005
    Location
    Madrid (Spain)
    Posts
    511

    Re: ODBC problem updating from Visual Studio 2005 to 2012

    Hi

    m_pTblPlot is not defined.... can you post a example that we can compile?

  3. #3
    Join Date
    Dec 2009
    Posts
    2

    Re: ODBC problem updating from Visual Studio 2005 to 2012

    m_pTblPlot is a clase member defined in the header as a pointer to the class CTblPlot which is inheirited from CRecorset. CTblPlot contains members for all the columns in the database table.

    /////////////////////////////////////////////////////////////////////////////
    // CTblPlot recordset

    class CTblPlot : public CRecordset
    {
    public:
    CTblPlot(CDatabase* pDatabase = NULL);

    // Field/Param Data
    //{{AFX_FIELD(CTblPlot, CRecordset)
    long m_ID;
    CString m_PlateName;
    float m_XMin;
    float m_XMax;
    float m_YMin;
    float m_YMax;
    float m_YInc;
    float m_XInc;
    //}}AFX_FIELD


    // Implementation
    protected:
    virtual CString GetDefaultConnect(); // Default connection string
    virtual CString GetDefaultSQL(); // Default SQL for Recordset
    virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support
    DECLARE_DYNAMIC(CTblPlot)
    };

    The whole application is thousands of lines of code and to run it you need multiple databases and a special database file structure. Not practical to provide a simple example that you could compile and run.
    Last edited by mccreary70; June 29th, 2013 at 07:38 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center