Solved CLOB

Posted on 2005-05-05
Last Modified: 2012-05-05
I have Oracle 8i
This gives an output in form of inverted questions marks instead of the characters..

Private Function tryInsertToClob(ByVal filename As String)As Boolean

        Dim strDBConnectionString As String = "Data Source=yy;user id=yy;Password=yy"
        Dim strOutputFolder As String = "c:\inetpub\webx\np_log\ControllerLog\"

        Dim conn As New OracleConnection(strDBConnectionString)
        Dim filePath As String
        Dim bigData As Byte()
        Dim t As Date
        Dim strFormat As String
        Dim fs As Stream
        Dim pos As Integer
        Dim jobId As Decimal
        Dim temp As String

            filePath = strOutputFolder & filename
            If Not File.Exists(filePath) Then
                Exit Function
            End If

                fs = File.OpenRead(filePath)
            Catch ex As Exception
            End Try

            Dim tempBuff(fs.Length) As Byte
            fs.Read(tempBuff, 0, fs.Length)


            Dim tx As OracleTransaction = conn.BeginTransaction()

            Dim cmd As New OracleCommand
            cmd = conn.CreateCommand()
            cmd.Transaction = tx
            cmd.CommandText = "SELECT id, clob_column FROM clob_content WHERE id = 111 for update"
            Dim myOracleDataReader As OracleDataReader = cmd.ExecuteReader()

            Dim myOracleClob As System.Data.OracleClient.OracleLob = myOracleDataReader.GetOracleLob(1)

             myOracleClob.Write(tempBuff, 0, tempBuff.Length)
            cmd.CommandText = "TestClob"
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New OracleParameter("ClobParam", OracleType.Clob)).Value = myOracleClob.Value
            cmd.Parameters.Add(New OracleParameter("v_id", OracleType.Number)).Value = 222
            cmd.Parameters("v_id").Direction = ParameterDirection.Input
            cmd.Parameters("ClobParam").Direction = ParameterDirection.Input
            Catch ex As Exception
            End Try
            Return True
        Catch ex As Exception
        End Try
    End Function
Question by:rishaan
    1 Comment
    LVL 96

    Accepted Solution

    Try this:

    Imports System.Text

        Dim readerInput As New StreamReader(filePath, Encoding.UTF8)

        Dim fileText As String = readerInput.ReadToEnd()

        Dim tempBuff() As Byte = Encoding.UTF8.GetBytes(fileText)


        myOracleClob.Write(tempBuff, 0, tempBuff.Length)


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now