how to save file from database to user's local disc

simonyong

Member
Joined
Aug 27, 2008
Messages
12
Programming Experience
Beginner
Hello, anyone
I had search for few days with how to save file when user choose a file name from listbox and i will search the file from database and user can save it into their desktop

what I had done currently is uploading a file to database but totally no idea about how to "download" from database

the following is my codes to upload file to database:

VB.NET:
If Not (myFile.PostedFile Is Nothing) Then

OpenConn()
Dim intFileNameLength As Integer, bytData() As Byte
Dim objStream As System.IO.Stream
Dim strFileNamePath As String
Dim strFileNameOnly As String

intFileNameLength = myFile.PostedFile.ContentLength
ReDim bytData(intFileNameLength)
objStream = myFile.PostedFile.InputStream
objStream.Read(bytData, 0, intFileNameLength)

strFileNamePath = myFile.PostedFile.FileName
intFileNameLength = InStr(1, StrReverse(strFileNamePath), "\")
strFileNameOnly = Mid(strFileNamePath, (Len(strFileNamePath) - intFileNameLength) + 2)

Dim cmd As OracleCommand
cmd = New OracleCommand("INSERT INTO test (filename, filesave) Values ('" + strFileNameOnly + "',:1)", myCN)
cmd.CommandType = CommandType.Text

Dim param As OracleParameter = cmd.Parameters.Add("filesave", OracleDbType.Blob) ' Bind the parameter as OracleDbType.Blob to command for inserting image
param.Direction = ParameterDirection.Input

param.Value = bytData ' Assign Byte Array to Oracle Parameter
cmd.ExecuteNonQuery()

CloseConn()
Label1.Text = "File Upload Success."
End If
Please help me/ giv me some direction to go, I hav no idea at all
Thanks in advance
 
Last edited by a moderator:

simonyong

Member
Joined
Aug 27, 2008
Messages
12
Programming Experience
Beginner
I already read it before i post this thread, im not clear what should i do for my application,please giv some actual direction
very sorry to tell u that im still student and no money to buy a upgraded version
 

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,052
Programming Experience
10+
VS 2008 Express is free!

I dont generally give advice on 2003 because it is very old and I stopped using it. The DW1 link is there as a nicety. If you were using a more modern version of VS I could tell you where to go exactly. As it is you will just have to read DW1 and look for a section that is an introduction, or a "First Simple Application" type thing
 
Top Bottom