如何将图片以二进制的形式存入数据库?
在Winform中,如果将图片以二进制的形式存入数据库?求各位大侠帮帮忙
------最佳解决方案--------------------字段:1.id 自增长2.img ole对象详细实现代码:default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>无标题页</title></head><body> <form id="form1" runat="server"> <div> <asp:FileUpload ID="FileUpload1" runat="server" /><br /> <br /> <asp:Button ID="Button1" runat="server" Text="上传" OnClick="Button1_Click" /></div> </form></body></html>default.aspx.csusing System;using System.Data;using System.Configuration;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.OleDb;using System.IO;public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { try { if (FileUpload1.HasFile) { if (IsAllowedExtension(this.FileUpload1)) { //取得上传文件的大小 int FileLen = FileUpload1.PostedFile.ContentLength; Byte[] FileData = new Byte[FileLen]; //创建访问客户端上传文件的对象 HttpPostedFile hp = FileUpload1.PostedFile; //创建数据流对象 Stream sr = hp.InputStream; //将图片数据放到FileData数组对象实例中,0代表数组指针的起始位置,FileLen代表指针的结束位置 sr.Read(FileData, 0, FileLen); OleDb