CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 4 of 4

Thread: VB application Uploading files(Blobs) into Oracle

  1. #1
    Join Date
    Jan 2021

    VB application Uploading files(Blobs) into Oracle

    Hello everyone I am new on here.

    I have a simple application that uploads text files into oracle as blobs. These files have text in them.

    I just noticed that if the text has french accent characters in it then when I upload the blobs those characters get corrupt.

    I also doubled check the Encoding for the database and it appears correct. We are using an Oracle Database.
    I am thinking that I some how need to encode the Blob I am uploading.


    How to I go about adding UTL 8 encoding when I am uploading a blob.

            Dim command1 As New OracleCommand(SQLStr, conn)
                If conn.State = ConnectionState.Open Then
                        Console.WriteLine("Connected to database!")
                    ' provide read access to the file
                    Dim Fs As FileStream = New FileStream(SourceLoc,
                                                   FileMode.Open, FileAccess.Read)
                        ' Create a byte array of file stream length
                        Dim ImageData As Byte()
                        ReDim ImageData(Fs.Length)
                        'Read block of bytes from stream into the byte array
                        Fs.Read(ImageData, 0, System.Convert.ToInt32(Fs.Length))
                        'Close the File Stream
                    SQLStr = SQLStr & " Update " & TableName & " Set BIN_DATA = :1 where FILENAME = :2"
                    ' Set command to create Anonymous PL/SQL Block
                    Dim command As New OracleCommand() '(StrSQL, conn)
                        command.CommandText = SQLStr
                        command.Connection = conn
                    ' Since executing an anonymous PL/SQL block, setting the command type
                    ' as Text instead of StoredProcedure
                    command.CommandType = CommandType.Text
                    Dim param1 As OracleParameter = command.Parameters.Add("BIN_DATA", OracleDbType.Blob) 'BIN_DATA (BLOB)
                    param1.Direction = ParameterDirection.Input
                    ' Assign Byte Array to Oracle Parameter
                    param1.Value = ImageData
                    Dim param2 As OracleParameter = command.Parameters.Add("FILENAME", OracleDbType.Varchar2) 'FILENAME
                    param2.Size = 50
                    param2.Direction = ParameterDirection.Input
                    ' Assign Byte Array to Oracle Parameter
                    param2.Value = File
                        'Console.WriteLine("Image file inserted to database from " + SourceLoc)
                        lblValidateSuccessfull.Text = "File has been uploaded to " & RBOracleServer.SelectedValue & " database. "
                    End If
                Catch ex As Exception
                End Try

  2. #2
    Join Date
    Jan 2021

    Re: VB application Uploading files(Blobs) into Oracle

    Thank you for any information you can give me.

  3. #3
    Join Date
    Jan 2021

    Re: VB application Uploading files(Blobs) into Oracle

    I am just wondering if maybe I am not explaining myself well. Lot's of looks but not any comments

  4. #4
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012

    Re: VB application Uploading files(Blobs) into Oracle

    Try the sister vb site which has a more active VB forum.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++20 Compiler: Microsoft VS2019 (16.9.0)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)