高分!ASP.NET中如何把图片以二进制方式存入SQL Server数据库,并能读取出来

来源:百度知道 编辑:UC知道 时间:2024/09/25 21:25:08
利用DataList控件显示,最好有完整实例,如能解决此问题,小弟可以再追加20-30分,绝不食言!!

1、建所需数据库和表,语句如下:

--建立数据库
create database test

--使用该数据库
use test

--建立存放图片的表
create table piclist(
id int Identity primary key,
pic Image not null
)

2、制作上传图片的模块,代码如下:
前台html代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="UpPhoto.aspx.cs" Inherits="Test_UpPhoto" %>

<!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" r