.net中把图片上传到数据库

来源:百度知道 编辑:UC知道 时间:2024/05/23 17:57:30
.net中把图片上传到数据库和从数据库中读取;最好给个实例惑详细源码;小弟在此谢谢了,看了他们得提问还是看不懂,那位高手帮下啊!急急急!!!!

//上传文件:upload.aspx
<%@ Page Language="C#" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<%@ import Namespace="System.IO" %>
<script runat="server">

public void AddPerson(object sender, EventArgs e)
{
Int64 intImageSize;
string strImageType;
Stream ImageStream ;

intImageSize = PersonImage.PostedFile.ContentLength;

strImageType = PersonImage.PostedFile.ContentType;

ImageStream = PersonImage.PostedFile.InputStream;

Byte[] ImageContent = new Byte[intImageSize];

int intStatus= ImageStream.Read(ImageContent,0,PersonImage.PostedFile.ContentLength);

OleDbConnection MyConnection = new OleDbConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" Server.MapPath("ps.mdb"));
OleDbCommand MyCommand = new OleDbCommand("INSERT I