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. General Programming
  3. C / C++ / MFC
  4. problem in inserting image into the database

problem in inserting image into the database

Scheduled Pinned Locked Moved C / C++ / MFC
databasec++helporacledata-structures
3 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
    maharaja pandian
    wrote on last edited by
    #1

    hi, i develop one application in VC++-MFC 6.0 , this application is responsible for inserting image into the database (oracle)-ODBC. but when i try to insert a image file , it through a error like "Data type conversion error." //////////////////////////////////////////////////////////////////////// CDaoDatabse db; CDaoRecordset recset(&db); void CDBODBC::InsertintoDB(); { CByteArray BlobFile; BlobFile.RemoveAll(); // I clear the Array CFile aFile("image.jpg",CFile::modeRead); BlobFile.SetSize(aFile.GetLength()); aFile.Read(BlobFile.GetData(),aFile.GetLength()); aFile.Close(); COleVariant aVar(BlobFile); CString Sql = "SELECT * FROM sample3"; db.Open("abc",FALSE,FALSE,"ODBC;UID=abc;PWD=abc;DSN=abc;"); recset.Open(AFX_DAO_USE_DEFAULT_TYPE,Sql,dbAppendOnly); // bool b=recset.CanUpdate(); recset.AddNew(); recset.SetFieldValue("[num]","6"); //varchar field recset.SetFieldValue("[photo]",aVar); //BLOB field -image field recset.Update(); recset.Close(); db.Close(); } ///////////////////////////////////// it works for Access database .. but i got error in oracle... "Data type conversion error." Try again and again, At last you will say I don't know the meaning for impossible.,.

    stefanmihaimogaS 1 Reply Last reply
    0
    • M maharaja pandian

      hi, i develop one application in VC++-MFC 6.0 , this application is responsible for inserting image into the database (oracle)-ODBC. but when i try to insert a image file , it through a error like "Data type conversion error." //////////////////////////////////////////////////////////////////////// CDaoDatabse db; CDaoRecordset recset(&db); void CDBODBC::InsertintoDB(); { CByteArray BlobFile; BlobFile.RemoveAll(); // I clear the Array CFile aFile("image.jpg",CFile::modeRead); BlobFile.SetSize(aFile.GetLength()); aFile.Read(BlobFile.GetData(),aFile.GetLength()); aFile.Close(); COleVariant aVar(BlobFile); CString Sql = "SELECT * FROM sample3"; db.Open("abc",FALSE,FALSE,"ODBC;UID=abc;PWD=abc;DSN=abc;"); recset.Open(AFX_DAO_USE_DEFAULT_TYPE,Sql,dbAppendOnly); // bool b=recset.CanUpdate(); recset.AddNew(); recset.SetFieldValue("[num]","6"); //varchar field recset.SetFieldValue("[photo]",aVar); //BLOB field -image field recset.Update(); recset.Close(); db.Close(); } ///////////////////////////////////// it works for Access database .. but i got error in oracle... "Data type conversion error." Try again and again, At last you will say I don't know the meaning for impossible.,.

      stefanmihaimogaS Offline
      stefanmihaimogaS Offline
      stefanmihaimoga
      wrote on last edited by
      #2

      The solution you may found it in Shekar Narayanan's Using CLongBinary for BLOBs[^] :)

      M 1 Reply Last reply
      0
      • stefanmihaimogaS stefanmihaimoga

        The solution you may found it in Shekar Narayanan's Using CLongBinary for BLOBs[^] :)

        M Offline
        M Offline
        maharaja pandian
        wrote on last edited by
        #3

        tnx, but , it is MSACCESS database with the column datatype of "OLE Object" so using COleVariant class,we convert the image as bytestream to COlevariant.. but i want to do the same thing for oracle ..with the column datatype "BLOB" here also i create same COleVariant ,but it doesn't acceptable by database field "BLOB"..... "Data type Conversion error" Try again and again, At last you will say I don't know the meaning for impossible.,.

        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