Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Opening a CRecordset derived class problem

Opening a CRecordset derived class problem

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpxmltutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Munkijo
    wrote on last edited by
    #1

    I am currently working on a system that uses an Access database to store a list of url's waiting to be processed. I need to be able to add to, and amend the database, and so, I have derived a class from the CRecordset class called CURLRecordset using the classwizard. In my application, I can succesfully open a CDatabase object in order to connect to the database, but when it comes to opening the actual recordsets associated with it: /* CURLRecordset* unparsed_urls; CDatabase* db; CString sql; */ unparsed_urls = new ( CUnparsed ) ( db ); sql.Format ( "SELECT * FROM urls WHERE status = %d;", STATUS_NOT_CRAWLED ); unparsed_urls->Open ( CRecordset::snapshot, (LPCTSTR)sql ); I get the following exception: "Invalid character value for cast specification on column number 2 (urladdress)" I have traced the source of the exception to the final move() function call in the CRecordset class's Open() method, but I have no idea how to deal with it. My database schema is as follows: TABLE urls = ( long urlid (PRIMARY KEY) VARCHAR(256) urladdress long status long level long keywordid long sourceid ) The header file for the CURLRecordset class is as follows: class CURLRecordset : public CRecordset { public: CURLRecordset(CDatabase* pDatabase = NULL); DECLARE_DYNAMIC(CURLRecordset) // Field/Param Data //{{AFX_FIELD(CURLRecordset, CRecordset) long m_keywordid; long m_level; long m_sourceid; long m_status; CString m_urladdress; long m_urlid; //}}AFX_FIELD // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CURLRecordset) public: virtual CString GetDefaultConnect(); // Default connection string virtual CString GetDefaultSQL(); // Default SQL for Recordset virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support //}}AFX_VIRTUAL // Implementation #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; Any help will be greatly appreciated!

    C 1 Reply Last reply
    0
    • M Munkijo

      I am currently working on a system that uses an Access database to store a list of url's waiting to be processed. I need to be able to add to, and amend the database, and so, I have derived a class from the CRecordset class called CURLRecordset using the classwizard. In my application, I can succesfully open a CDatabase object in order to connect to the database, but when it comes to opening the actual recordsets associated with it: /* CURLRecordset* unparsed_urls; CDatabase* db; CString sql; */ unparsed_urls = new ( CUnparsed ) ( db ); sql.Format ( "SELECT * FROM urls WHERE status = %d;", STATUS_NOT_CRAWLED ); unparsed_urls->Open ( CRecordset::snapshot, (LPCTSTR)sql ); I get the following exception: "Invalid character value for cast specification on column number 2 (urladdress)" I have traced the source of the exception to the final move() function call in the CRecordset class's Open() method, but I have no idea how to deal with it. My database schema is as follows: TABLE urls = ( long urlid (PRIMARY KEY) VARCHAR(256) urladdress long status long level long keywordid long sourceid ) The header file for the CURLRecordset class is as follows: class CURLRecordset : public CRecordset { public: CURLRecordset(CDatabase* pDatabase = NULL); DECLARE_DYNAMIC(CURLRecordset) // Field/Param Data //{{AFX_FIELD(CURLRecordset, CRecordset) long m_keywordid; long m_level; long m_sourceid; long m_status; CString m_urladdress; long m_urlid; //}}AFX_FIELD // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CURLRecordset) public: virtual CString GetDefaultConnect(); // Default connection string virtual CString GetDefaultSQL(); // Default SQL for Recordset virtual void DoFieldExchange(CFieldExchange* pFX); // RFX support //}}AFX_VIRTUAL // Implementation #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif }; Any help will be greatly appreciated!

      C Offline
      C Offline
      Chad Koehler
      wrote on last edited by
      #2

      I think the problem may be in your DoFieldExchange() function...I can't think of anywhere else that the problem could be.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups