Pls Help... ASP.NET Upload File to Access Database Question
-
Hi Hi All, I'm trying to write a program to Upload file to a Access Database. ( for example word, excel file ). I have read some ASP.NET's book. they have sample code upload file to a folder But Not upload to a Access Database. Can any one give me sample code for Upload file to Access. Many Many Thanks, Ken
-
Hi Hi All, I'm trying to write a program to Upload file to a Access Database. ( for example word, excel file ). I have read some ASP.NET's book. they have sample code upload file to a folder But Not upload to a Access Database. Can any one give me sample code for Upload file to Access. Many Many Thanks, Ken
hi there, plz have alook on it, http://www.stardeveloper.com/articles/display.html?article=2003031201&page=1[^] wish you solve ur problem :) Any systematic work reflects its significance for a long time, Though I m not totally against "The Prototyping".So let's discuss in depth...
-
Hi Hi All, I'm trying to write a program to Upload file to a Access Database. ( for example word, excel file ). I have read some ASP.NET's book. they have sample code upload file to a folder But Not upload to a Access Database. Can any one give me sample code for Upload file to Access. Many Many Thanks, Ken
Below is a sample for the upload of an image. It is not much different with word docs <%@ Import Namespace="System.io"%> <%@ Import Namespace="System.Drawing.Imaging"%> <%@ Import Namespace="System.Data.OleDb"%> <%@ Page Language="vb"%> Superfeet Private Sub Page_Load() 'Put user code to initialize the page here End Sub Sub doUpdate(s As Object, e As EventArgs) 'Making the Enter key call btnSearch_Click Page.RegisterHiddenField("__EVENTTARGET", "doUpdate") txtvolledige_tekst.Text = Server.HtmlEncode(txtvolledige_tekst.Text) Dim ConnStr As String Dim OleDb As String ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=C:\Inetpub\wwwroot\yourprojectfolder\yourdatabase.mdb;" OleDb = "Insert into sf_nieuwsartikel ( " OleDb += " titel " OleDb += " , volgorde " OleDb += " , volledige_tekst " OleDb += " , foto " OleDb += " ) values ( " OleDb += " @par_titel" OleDb += " , @par_volgorde " OleDb += " , @par_volledige_tekst" OleDb += " , @par_foto" OleDb += " )" Dim myOleDbconn As New OleDbConnection(ConnStr) Dim myOleDbcommand As New OleDbCommand(OleDb, myOleDbconn) myOleDbcommand.Connection.Open() Dim SourceFile As HttpPostedFile SourceFile = Request.Files(0) Dim br As BinaryReader = New BinaryReader(SourceFile.InputStream) Dim photo() As Byte = br.ReadBytes(SourceFile.InputStream.Length) br.Close() With myOleDbcommand.Parameters .Add(New OleDbParameter("@par_titel", OleDbType.VarChar)).Value = txttitel.Text.Trim .Add(New OleDbParameter("@par_volgorde", OleDbType.VarChar)).Value = txtvolgorde.Text.Trim .Add(New OleDbParameter("@par_volledige_tekst", OleDbType.VarChar)).Value = txtvolledige_tekst.Text.Trim .Add(New OleDbParameter("@par_foto", OleDbType.LongVarBinary, photo.Length)).Value = photo End With myOleDbcommand.ExecuteNonQuery() myOleDbcommand.Connection.Close() Response.Redirect("nieuwsartikel_tgv.html") End Sub