klt13
asked on
How to download BLOB data from SQL database
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(Configuratio nManager.C onnectionS trings("In tranetConn ectionStri ng").Conne ctionStrin g)
Dim fn As String
fn = FileUpload2.FileName.ToStr ing.Trim
Dim SQL As String
SQL = "INSERT INTO [Trouble_Ticket_Uploads] ([wo], [filename],[fileobject]) VALUES ('" & Request.QueryString("ID"). Trim & "','" & FileUpload2.FileName.ToStr ing.Trim & "', @Data)"
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim imageBytes(FileUpload2.Pos tedFile.In putStream. Length) As Byte
FileUpload2.PostedFile.Inp utStream.R ead(imageB ytes, 0, imageBytes.Length)
myCommand.Parameters.AddWi thValue("@ Data", imageBytes)
myConnection.Open()
myCommand.ExecuteNonQuery( )
myConnection.Close()
Label20.Text = "File uploaded successfully!"
SqlDataSource7.SelectComma nd = "select * from trouble_ticket_uploads where [wo] like '%" & Request.QueryString("ID"). Trim & "%'"
GridView7.DataBind()
RESOLV.Focus()
End Using
Now I'm looking for code to get it back out. Thanks in advance.
here is my upload code:
Using myConnection As New SqlConnection(Configuratio
Dim fn As String
fn = FileUpload2.FileName.ToStr
Dim SQL As String
SQL = "INSERT INTO [Trouble_Ticket_Uploads] ([wo], [filename],[fileobject]) VALUES ('" & Request.QueryString("ID").
Dim myCommand As New SqlCommand(SQL, myConnection)
Dim imageBytes(FileUpload2.Pos
FileUpload2.PostedFile.Inp
myCommand.Parameters.AddWi
myConnection.Open()
myCommand.ExecuteNonQuery(
myConnection.Close()
Label20.Text = "File uploaded successfully!"
SqlDataSource7.SelectComma
GridView7.DataBind()
RESOLV.Focus()
End Using
Now I'm looking for code to get it back out. Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
WARNING!!!!!
Although I posted that I had found a way to download this data, sadly to say, this will download it to the server and NOT the client PC. I thought I was putting it in my C:\temp directory, but it never showed up. I found it in the temp directory located on the server.
Still looking.....
Although I posted that I had found a way to download this data, sadly to say, this will download it to the server and NOT the client PC. I thought I was putting it in my C:\temp directory, but it never showed up. I found it in the temp directory located on the server.
Still looking.....
Open in new window