ASP.Net Upload Image to MS Access Database

by top54u.com 29 Feb, 2008
Spotlight.....

As you learnt from the previous articles to upload image to the SQL Database in ASP.Net 2.0 and stream that image into the memory to retrieve it from the database and display it on the web page. In this article you will learn how to upload images to the MS Access database in ASP.Net 2.0

 

First of all create an Access Database and place it in the App_Data folder of ASP.Net web site project. Then create a table “tblImg” with the following fields:

  1. img_id datatype number

  2. img_title datatype Text

  3. img_type datatype Text

  4. img_stream datatype OLE Object

 

Notice the field img_stream, it has datatype OLE Object. In this field you can store the binary stream of the image passed by ASP.Net code.

 

To access the MS Access database you can use the following code:

 

' Access Database oledb connection string

' Using Provider Microsoft.Jet.OLEDB.4.0

Dim connStr As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("App_Data/db1.mdb")

' Object created for Oledb Connection

Dim myAccessConnection As New OleDbConnection(connStr)

 

To use OleDbConnection you must import the following namespaces:

 

Imports System.Data

Imports System.Data.OleDb

To upload the image to the MS Access database field you can pass the binary stream through the OleDb Command Parameter of type OleDbType.Binary

continue next...

VB Code to Upload Image to MS Access Database in ASP.Net

Store and Display Images from MS Access Database Using C#

Spotlight.....

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

8/23/2008 8:46:18 PM

OUR SPONSORS[+ advertise here]
related videos.....
recent posts.....
top54u ezines.....