?
Solved

vb.net CLOB

Posted on 2005-05-05
3
Medium Priority
?
900 Views
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
        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
0
Comment
Question by:rishaan
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 13939526
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

850 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