Problem in retrieving RTF data stored in DB as varbinary(max).

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • appsols
    New Member
    • May 2014
    • 1

    Problem in retrieving RTF data stored in DB as varbinary(max).

    Dear All!

    I have RTF formatted data stored in the database as varbinary(max). I want to retrieve all data and store it in word document using while loop. However, the first record is correctly retrieved while the rest are ignored. I have queried other non-binary fields and they are correctly display in the output document. Please check my codes and suggest necessary correction...
    my code is hereunder:

    Code:
    Dim Path As String = "D:\Test.doc"
            Dim sw As New System.IO.StreamWriter(Path, False)
            Dim cmd As New SqlCommand("select * from APG_LQs", cn)
            If Not cn.State = ConnectionState.Open Then
                cn.Open()
            End If
            rd = cmd.ExecuteReader()
            If rd.HasRows Then
                While rd.Read
                    sw.WriteLine(System.Text.Encoding.Default.GetString(rd("QuestionFormatted")))
                End While
            End If
            cn.Close()
            sw.Flush()
            sw.Close()
    expecting a quick and prompt response:

    Ali
    Last edited by Rabbit; May 5 '14, 04:02 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...