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
5 Posts 3 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=abcWD=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.,.

    D V 2 Replies 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=abcWD=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.,.

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      See if this helps. maharaja pandian wrote: CDaoRecordset recset(&db); In addition, if you would derive a class from CDaoRecordset, the RFX_Binary() code would handle the details for you.


      "The largest fire starts but with the smallest spark." - David Crow

      "Judge not by the eye but by the heart." - Native American Proverb

      M 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=abcWD=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.,.

        V Offline
        V Offline
        Viorel
        wrote on last edited by
        #3

        Perhaps for long data type as BLOB you have to use CDaoQueryDef instead of CDaoRecordset. See the problem with BLOB type at http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B168447[^].

        M 1 Reply Last reply
        0
        • V Viorel

          Perhaps for long data type as BLOB you have to use CDaoQueryDef instead of CDaoRecordset. See the problem with BLOB type at http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B168447[^].

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

          tnx for ur reply, but COleVariant is used to store the "OLE object" datatype in .MDB database. when i use oracle DB , the corresponding BLOB datatype is not get matched with COleVariant class in VC++. I got the error like " Data type conversion error" can u please send the details to store the oracle BLOB value throuh VC++. Try again and again, At last you will say I don't know the meaning for impossible.,.

          1 Reply Last reply
          0
          • D David Crow

            See if this helps. maharaja pandian wrote: CDaoRecordset recset(&db); In addition, if you would derive a class from CDaoRecordset, the RFX_Binary() code would handle the details for you.


            "The largest fire starts but with the smallest spark." - David Crow

            "Judge not by the eye but by the heart." - Native American Proverb

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

            tnx for ur reply, but COleVariant is used to store the "OLE object" datatype in .MDB database. when i use oracle DB , the corresponding BLOB datatype is not get matched with COleVariant class in VC++. I got the error like " Data type conversion error" can u please send the details to store the oracle BLOB value throuh VC++. 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