Signup · Login
Stardeveloper.com  
Home · Tutorials · Forums · Web Hosting Plans · Faisal Khan's Blog · Contact
Search Stardeveloper.com
Stardeveloper RSS Feed
Newsletter
Enter your email address below to be informed every time a new article is posted at Stardeveloper.com:

You can follow Faisal Khan on Twitter
Article Categories
.NET  .NET
  ASP (16)
  ASP.NET (41)
  ADO (16)
  ADO.NET (10)
  COM (6)
  Web Services (4)
  C# (1)
  VB.NET (3)
  IIS (2)

J2EE  J2EE
  JSP (15)
  Servlets (9)
  Web Services (1)
  EJB (4)
  JDBC (4)
  E-Commerce (1)
  J2ME (1)
  Products (1)
  Applets (1)
  Patterns (1)
Log In
UserName Or Email:

Password:

Auto-Login:

Miscellaneous Links
  Submit Article

Hosted by Securewebs.com
 
Home : .NET : ASP.NET : File Uploading to Access Database using ASP.NET
 

File Uploading to Access Database using ASP.NET

by Faisal Khan.Follow Faisal Khan on Twitter

Overview
In this article we will learn how to upload one or more files from the client browser to a Microsoft Access database using plain ASP.NET. We will not be creating or making use of any commercial or home-made components, instead we will learn to make use of standard ASP.NET HTML controls which are part of ASP.NET 1.0.

Uploading files to Microsoft Access is very useful and we'll learn in this article how to do that.

File Uploading Using Plain ASP
If you are looking to upload files using plain ASP ( VBScript ) then here are few links to popular Stardeveloper articles on how to do it:

  1. File uploading to server hard disk.
  2. Uploading files ( binary data ) to the database.
  3. Displaying files ( binary data ) from the database.

File Uploading Using ASP.NET
Here are few Stardeveloper articles on this topic:

  1. File uploading to server hard disk.
  2. File uploading to Microsoft Access database ( this article ).
  3. Uploading images, determining size, width & height and resizing image files.

Problem
Let's first consider what we want to do. We want to:

  1. Upload one or more files to Microsoft Access database.
  2. Allow the user to select the files and leave the file input boxes empty if he/she doesn't want to upload. We should handle this situation gracefully.
  3. Also provide other form options like input boxes for first and last names, favorite programming languages etc so that we learn how to receive regular form post data along with binary file data at the same time.
  4. View all the uploaded files.
  5. Allow the user to view the file online.
  6. Allow the user to be forced to download file. We'll see how this is done.
  7. Delete uploaded files.
  8. Set maximum file upload size limit.

Design
Our design comprises of following files:

  • Microsoft Access database:
    1. Files.mdb ( a data store for all the uploaded files )
  • Class file:
    1. GenericPage.cs ( base class for all of our code-behind classes )
  • 3 ASP.NET pages:
    1. default.aspx ( list all files )
    2. upload.aspx ( upload one or more files )
    3. file.aspx ( view, delete or download a file from database )
  • Optional files:
    1. build.bat ( a batch files to generate an assembly )
    2. Web.config ( to allow or restrict uploading of large files )

Solution
Let's code and build the solution.

i. Files.mdb
First of all we need to create a Microsoft Access database which can later be used to store uploaded files. You can use this Access database on your ASP.NET web site without worrying to pay additional licensing fees to your host. Making use of your Access database is offered free of cost by all the ASP.NET hosts.

You'll be needing Microsoft Access 2000 installed on your system in order to create this database. Just in case if you don't have Access 2000 ( or 2002 ) then don't worry, you can download the zip file at the end of this tutorial which contains a pre-built Access 2000 database. You can then use that Access 2000 database on your system or upload it to your server hard disk as you like.

Tip: No need to buy Microsoft Access 2000 ( or 2002 ) to make use of this tutorial.

Overview
In this article we will learn how to upload one or more files from the client browser to a Microsoft Access database using plain ASP.NET. We will not be creating or making use of any commercial or home-made components, instead we will learn to make use of standard ASP.NET HTML controls which are part of ASP.NET 1.0.

Uploading files to Microsoft Access is very useful and we'll learn in this article how to do that.

File Uploading Using Plain ASP
If you are looking to upload files using plain ASP ( VBScript ) then here are few links to popular Stardeveloper articles on how to do it:

  1. File uploading to server hard disk.
  2. Uploading files ( binary data ) to the database.
  3. Displaying files ( binary data ) from the database.

File Uploading Using ASP.NET
Here are few Stardeveloper articles on this topic:

  1. File uploading to server hard disk.
  2. File uploading to Microsoft Access database ( this article ).
  3. Uploading images, determining size, width & height and resizing image files.

Problem
Let's first consider what we want to do. We want to:

  1. Upload one or more files to Microsoft Access database.
  2. Allow the user to select the files and leave the file input boxes empty if he/she doesn't want to upload. We should handle this situation gracefully.
  3. Also provide other form options like input boxes for first and last names, favorite programming languages etc so that we learn how to receive regular form post data along with binary file data at the same time.
  4. View all the uploaded files.
  5. Allow the user to view the file online.
  6. Allow the user to be forced to download file. We'll see how this is done.
  7. Delete uploaded files.
  8. Set maximum file upload size limit.

Design
Our design comprises of following files:

  • Microsoft Access database:
    1. Files.mdb ( a data store for all the uploaded files )
  • Class file:
    1. GenericPage.cs ( base class for all of our code-behind classes )
  • 3 ASP.NET pages:
    1. default.aspx ( list all files )
    2. upload.aspx ( upload one or more files )
    3. file.aspx ( view, delete or download a file from database )
  • Optional files:
    1. build.bat ( a batch files to generate an assembly )
    2. Web.config ( to allow or restrict uploading of large files )

Solution
Let's code and build the solution.

i. Files.mdb
First of all we need to create a Microsoft Access database which can later be used to store uploaded files. You can use this Access database on your ASP.NET web site without worrying to pay additional licensing fees to your host. Making use of your Access database is offered free of cost by all the ASP.NET hosts.

You'll be needing Microsoft Access 2000 installed on your system in order to create this database. Just in case if you don't have Access 2000 ( or 2002 ) then don't worry, you can download the zip file at the end of this tutorial which contains a pre-built Access 2000 database. You can then use that Access 2000 database on your system or upload it to your server hard disk as you like.

Tip: No need to buy Microsoft Access 2000 ( or 2002 ) to make use of this tutorial.

 ( 13 Remaining ) Next

See all comments and questions (post-ad) posted for this tutorial.


Comments/Questions ( Threads: 49, Comments: 125 )
    Contains 1 or more replies by the Author of this Article.
    Contains 1 or more replies by Faisal Khan.

  1. Regarding Image File Uploading/Downloading
  2. removing
  3. need to index wepages in to database of a search engine
  4. Uploading Data from a Text File to SQL Server Table
  5. Can't find the correct drive
  6. Viewing the output of this tutorial ( 1 Reply )
  7. help on File Uploading to Access Database using ASP.NET
  8. Cant Access GetURL.dll
  9. uploading to access in asp.net from Fasal khan
  10. Putting the database in a folder outside the www root ... ?
  11. Error in the downloaded file
  12. Facing Problem in File Uploading to Access Database using ASP.NET
  13. DIfference between adding files to the database and to server
  14. Adding Fields ( 1 Reply )
  15. Critical Improvement - Preventing File Corruption
  16. File Upload Error ( 1 Reply )
  17. C# Application over NetWork
  18. Parser Error when running default.aspx ( 1 Reply )
  19. execute the compiler access denied error ( 2 Replies )
  20. UPDATING THE DIV IN DEFAULT.ASPX WITHOUT POSTING
  21. Mixing two techniques
  22. Questions about sorting ( 1 Reply )
  23. Visual Studio web form designer cannot load files ( 2 Replies )
  24. Why the tutorial does not close the DB connections ? ( 1 Reply ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  25. I can not used this in VS.NET
  26. The file failed to load in the Web Form designer .... Type Abstract ( 1 Reply )
  27. Uploading to MySQL help (can't afford SQL Server)
  28. Parser Error Message: Could not load type 'Stardeveloper.UploadAccess.DefaultForm'. ( 4 Replies )
  29. Displaying pictures and data in ASP.Net using Access as Database ( 1 Reply )
  30. Error after compile file upload to access
  31. Error after compilng !!!! upload to access database
  32. error occured while executing build.bat
  33. Excellent tutorial - Works perfectly even for Microsoft SQL Server ( 1 Reply ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  34. Error occured while executing build,bat ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  35. Error Occurred: Operation must use an updateable query. ( 5 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  36. Upload Error ( 1 Reply ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  37. Inherits Command ( 3 Replies )
  38. Uploading/Displaying OLE Objects -- Ex: LINKED Word Document
  39. add form data to database ( 3 Replies )
  40. Error with non-image files ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  41. Insert SQL command and values
  42. Convert C# to VB .Net ( 15 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  43. Error Compiling the Upload to ACCESS files ( 4 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  44. SQL - Uploading to a database. ( 6 Replies ) This thread contains 2 replies by the Author of this Article. This thread contains 2 replies by Faisal Khan.
  45. How to connect to database Access ( 5 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  46. Why uploading to an Acces Database? ( 4 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  47. How to execute build.bat ( 3 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  48. Locked database ( 4 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.
  49. Invalid procedure call or argument: 'MidB' ( 2 Replies ) This thread contains 1 reply by the Author of this Article. This thread contains 1 reply by Faisal Khan.

Post Comments/Questions

In order to post questions/comments, you must be logged-in. If you are not a member yet, then signup, otherwise login. Once you login then come back to this page and you'll see a form right here which will allow you to post comments/questions.

Please note, one of the benefits of signing up is to be notified immediately by email everytime you receive a reply to the thread you have subscribed to.

 
© 1999 - 2009 Stardeveloper.com, All Rights Reserved.