By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,641 Members | 1,446 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,641 IT Pros & Developers. It's quick & easy.

Writing out "Long Text" from SQL Server to a file

P: n/a
RON
have to read a long text field (it's a PDF stored in a column) from SQL
Server in a VB.NET (2003) app. Here's the code I have:

Sub GetPDF(byval Path as string)
'objConnection created elsewhere; not the problem
Dim da As SqlDataAdapter = New SqlDataAdapter(QUERYSTRING),
objConnection)
'query string will only return the Long Text column; and only one row
Dim ds As DataSet = New DataSet("JustAName")
Dim MyData(0) As Char '''original code was cloned from another procedure
which
'read a byte array. I didn't design the SQL Server DB; it's from a vendor.
'The column is Long Text; holds a PDF
da.Fill(ds, "PDF-TableName")
Dim myRow As DataRow
myRow = ds.Tables("PDF-TableName").Rows(0)
MyData = CType(myRow(0), Char())
Dim ArraySize As Integer = New Integer
ArraySize = MyData.GetLength(0)
'write operation
Dim fs As FileStream = New FileStream(path, FileMode.OpenOrCreate,
FileAccess.Write)
fs.Write(MyData, 0, ArraySize) '''<<<PROBLEM. NEEDS A BYTE array
fs.Close()
end sub
SUB doesn't work. BUT NOT SURE why.

ANY HELP IS GRATEFULLY APPRECIATED

RON
Nov 7 '06 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.