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:
expecting a quick and prompt response:
Ali
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()
Ali