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:
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#
Currently rated 5.0 by 1 people
Tags: asp.net 2.0, upload image to database, free source code, ms access
8/23/2008 8:46:18 PM