How to download BLOB data from SQL database
Posted on 2010-01-07
I have uploaded some blob data into a sql table. How I have this list displayed in a gridview and working off of the "select" option on the gridview, i want to download the blob data back to my local PC. I use VB.net so i would appreciate that type of code please.
here is my upload code:
Using myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("IntranetConnectionString").ConnectionString)
Dim fn As String
fn = FileUpload2.FileName.ToString.Trim
Dim SQL As String
SQL = "INSERT INTO [Trouble_Ticket_Uploads] ([wo], [filename],[fileobject]) VALUES ('" & Request.QueryString("ID").Trim & "','" & FileUpload2.FileName.ToString.Trim & "', @Data)"
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim imageBytes(FileUpload2.PostedFile.InputStream.Length) As Byte
FileUpload2.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)
Label20.Text = "File uploaded successfully!"
SqlDataSource7.SelectCommand = "select * from trouble_ticket_uploads where [wo] like '%" & Request.QueryString("ID").Trim & "%'"
Now I'm looking for code to get it back out. Thanks in advance.