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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Using MDB database with OLEDB/ATL/MFC (from SQL Server)

Using MDB database with OLEDB/ATL/MFC (from SQL Server)

Scheduled Pinned Locked Moved Database
databasec++sql-serversysadminhelp
1 Posts 1 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.
  • G Offline
    G Offline
    Gian
    wrote on last edited by
    #1

    I'm programming a little server application in MFC 7.1 + OLEDB that read from a database. I'm using a SQL Server DB (extactly the MSDE version) and all works good, but now i need to store the data in an Access 2000 file, so i've changed the connection parameters like this: CDBPropSet dbinit(DBPROPSET_DBINIT); HRESULT hr; dbinit.AddProperty(DBPROP_AUTH_USERID, OLESTR("Admin")); dbinit.AddProperty(DBPROP_AUTH_PASSWORD, OLESTR("")); dbinit.AddProperty(DBPROP_INIT_DATASOURCE, OLESTR("C:\\Gestu.mdb")); dbinit.AddProperty(DBPROP_INIT_MODE, (long)DB_MODE_READWRITE/*(long)16*/); dbinit.AddProperty(DBPROP_INIT_PROMPT, (short)DBPROMPT_NOPROMPT/*(short)4*/); dbinit.AddProperty(DBPROP_INIT_PROVIDERSTRING, OLESTR("")); dbinit.AddProperty(DBPROP_INIT_LCID, (long)1033); hr = m_DataSource.Open(_T("Microsoft.Jet.OLEDB.4.0"), &dbinit); if (FAILED(hr)) return false; hr = m_session.Open(m_DataSource); if (FAILED(hr)) return false; return true; } the program logins correctly. but when i try to execute a SELECT statement or other accessor operations and execute them it have an error DB_E_ERRORSINCOMMAND. a sample operation is: CCommand DynamicAccessor; CDBPropSet propset(DBPROPSET_ROWSET); propset.AddProperty(DBPROP_CANFETCHBACKWARDS, true); propset.AddProperty(DBPROP_IRowsetScroll, true); propset.AddProperty(DBPROP_IRowsetChange, true); propset.AddProperty(DBPROP_UPDATABILITY, DBPROPVAL_UP_CHANGE); DBROWCOUNT rows; CString sql; sql.Format("SELECT * FROM Users WHERE nickname = '%s';", strNickname); HRESULT hr; hr = DynamicAccessor.Open(m_session, sql, &propset, &rows); if (FAILED(hr)) return false; The same code here works perfectly with the SQL Server connection. Is there some parameters to modify? Thanks

    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