lidds Posted March 31, 2005 Posted March 31, 2005 I am uploading a file into a image field within a table. I am using the following code but what I want to be able to do display a progressbar for the user. The problem is that I am struggling to work out how to do this. Below is the code that I am using. Dim SourceLoc As String = "C:\temp\dxf file\exampleload.dxf" Dim myUploadCmd As New OleDb.OleDbCommand("UPDATE fileStorageTbl SET Picture=? WHERE Revision='0'", varProjSQLConn) Try Dim fileSize As New System.IO.FileStream(SourceLoc, IO.FileMode.Open, IO.FileAccess.Read) Dim b(fileSize.Length() - 1) As Byte objFrmStatus.txtStatus.Text = "Reading file, please wait..." objFrmStatus.Refresh() fileSize.Read(b, 0, b.Length) fileSize.Close() objFrmStatus.txtStatus.Text = "Uploading file to database, please wait..." objFrmStatus.Refresh() Dim p As New OleDb.OleDbParameter("@Picture", OleDb.OleDbType.LongVarBinary, b.Length, ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, b) myUploadCmd.Parameters.Add(p) varProjSQLConn.Open() myUploadCmd.ExecuteNonQuery() varProjSQLConn.Close() Catch ex As System.Data.SqlClient.SqlException MsgBox(ex.Message) End Try objFrmStatus.Close() MsgBox("File uploaded successfully", MsgBoxStyle.Information, "File Upload") Thanks Simon Quote
michael_hk Posted April 1, 2005 Posted April 1, 2005 You read the whole file by this single line fileSize.Read(b, 0, b.Length) so there won't be any intermediate step. You have to break down this process into steps, say read 8k each time, in order to show the user the progress. Quote There is no spoon. <<The Matrix>>
lidds Posted April 1, 2005 Author Posted April 1, 2005 Don't suppose anyone has an example of how to do this in vb.net Quote
Administrators PlausiblyDamp Posted April 1, 2005 Administrators Posted April 1, 2005 http://www.xtremedotnettalk.com/showthread.php?t=85665 may be worth a look Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.