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#
  4. Insert a word Document into database

Insert a word Document into database

Scheduled Pinned Locked Moved C#
databasehelptutorial
7 Posts 3 Posters 2 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.
  • K Offline
    K Offline
    kalyanPaladugu
    wrote on last edited by
    #1

    How should i insert a word document into database. I defined a Blob field in the database and i used this code FileStream fls; fls = new FileStream(path, FileMode.Open, FileAccess.Read); byte[] blob = new byte[fls.Length]; fls.Read(blob, 0, System.Convert.ToInt32(fls.Length)); fls.Close(); query = "insert into Example(BLOBField)values(:BlobParameter)"; OracleParameter blobParameter = new OracleParameter(); blobParameter.OracleType = OracleType.Blob; blobParameter.ParameterName = "BlobParameter"; blobParameter.Value = blob; conn.Open(); cmnd = new OracleCommand(query, conn); cmnd.Parameters.Add(blobParameter); cmnd.ExecuteNonQuery(); cmnd.Dispose(); conn.Close(); What am i doing wrong. Its throwing up an error. Is there any other way to do this. Thanks Kal

    N 1 Reply Last reply
    0
    • K kalyanPaladugu

      How should i insert a word document into database. I defined a Blob field in the database and i used this code FileStream fls; fls = new FileStream(path, FileMode.Open, FileAccess.Read); byte[] blob = new byte[fls.Length]; fls.Read(blob, 0, System.Convert.ToInt32(fls.Length)); fls.Close(); query = "insert into Example(BLOBField)values(:BlobParameter)"; OracleParameter blobParameter = new OracleParameter(); blobParameter.OracleType = OracleType.Blob; blobParameter.ParameterName = "BlobParameter"; blobParameter.Value = blob; conn.Open(); cmnd = new OracleCommand(query, conn); cmnd.Parameters.Add(blobParameter); cmnd.ExecuteNonQuery(); cmnd.Dispose(); conn.Close(); What am i doing wrong. Its throwing up an error. Is there any other way to do this. Thanks Kal

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      kalyanPaladugu wrote:

      Its throwing up an error.

      It might be helpful to say what the error is you are getting.


      only two letters away from being an asset

      K 1 Reply Last reply
      0
      • N Not Active

        kalyanPaladugu wrote:

        Its throwing up an error.

        It might be helpful to say what the error is you are getting.


        only two letters away from being an asset

        K Offline
        K Offline
        kalyanPaladugu
        wrote on last edited by
        #3

        ORA-00600:internal error code, arguments: [koklgloblen:bnd][],[],[],[],[],[],[] Thats the error its throwing. Iam able to insert ordinary values like int and varchar but not blobs

        K 1 Reply Last reply
        0
        • K kalyanPaladugu

          ORA-00600:internal error code, arguments: [koklgloblen:bnd][],[],[],[],[],[],[] Thats the error its throwing. Iam able to insert ordinary values like int and varchar but not blobs

          K Offline
          K Offline
          kalyanPaladugu
          wrote on last edited by
          #4

          I figured out the error. I was able to insert into the database. My second question is how should i retrieve it from the database. If i execute the statement select * from table name its showing as orablob in those columns i inserted. Is that the normal behaviour. Can some body provide the code to retrieve the word document from the database Thanks Kal

          L 1 Reply Last reply
          0
          • K kalyanPaladugu

            I figured out the error. I was able to insert into the database. My second question is how should i retrieve it from the database. If i execute the statement select * from table name its showing as orablob in those columns i inserted. Is that the normal behaviour. Can some body provide the code to retrieve the word document from the database Thanks Kal

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            kalyanPaladugu wrote:

            Can some body provide the code to retrieve the word document from the database

            Probably

            kalyanPaladugu wrote:

            I figured out the error. I was able to insert into the database.

            How about you share your solution. Its called give and take

            Objects in mirror are closer than they appear

            K 1 Reply Last reply
            0
            • L Lost User

              kalyanPaladugu wrote:

              Can some body provide the code to retrieve the word document from the database

              Probably

              kalyanPaladugu wrote:

              I figured out the error. I was able to insert into the database.

              How about you share your solution. Its called give and take

              Objects in mirror are closer than they appear

              K Offline
              K Offline
              kalyanPaladugu
              wrote on last edited by
              #6

              Its the same thing. The above code in the first link should work. Previously i was inserting into two blob fields in the database from the same file stream object and so it failed. So i created two file stream objects for two blob fields and it seem to work. So if you run the code as it is i posted it should work as it is only one blob field in the database and one file stream object to load that Thanks Kal

              K 1 Reply Last reply
              0
              • K kalyanPaladugu

                Its the same thing. The above code in the first link should work. Previously i was inserting into two blob fields in the database from the same file stream object and so it failed. So i created two file stream objects for two blob fields and it seem to work. So if you run the code as it is i posted it should work as it is only one blob field in the database and one file stream object to load that Thanks Kal

                K Offline
                K Offline
                kalyanPaladugu
                wrote on last edited by
                #7

                How to retrieve the data from the blob field in the database Thanks Kal

                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