vb.net CLOB

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
        Try

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

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

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

            conn.Open()

            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()
            myOracleDataReader.Read()

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

            myOracleClob.Erase()
             myOracleClob.Write(tempBuff, 0, tempBuff.Length)
           cmd.Parameters.Clear()
            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
            Try
                cmd.ExecuteNonQuery()
            Catch ex As Exception
                MsgBox(ex.message)
            End Try
            tx.Commit()
            Return True
        Catch ex As Exception
            MsgBox(ex.message)
        End Try
    End Function
rishaanAsked:
Who is Participating?
 
Bob LearnedCommented:
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)

Bob
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.