开发环境:window 2000、sqlserver2000、.net framework sdk正式版
开发语言:c#、asp.net
简介:数据库中图片存储及读取
说明:在asp中,我们用request.totalbytes、request.binaryread()来上传图片,这个可恶的binaryread()方法非常笨,单个文件上传倒没什么大事,单如果多个图片上专可就花大气力了…!而现在asp.net中将会把解决以前asp中文件上传的种种问题,使你在asp.net中轻轻松松开发出功能强大的上传程序,下面大家看看例子啦。
首先在sql server中建立一个图片存储的数库表,sqlscript如下:
if exists (select * from dbo.sysobjects where id = object_id(n"[dbo].[image]") and objectproperty(id, n"isusertable") = 1)
drop table [dbo].[image]
go
create table [dbo].[image] (
[img_pk] [int] identity (1, 1) not null ,
[img_name] [varchar] (50) null ,
[img_data] [image] null ,
[img_contenttype] [varchar] (50) null
) on [primary] textimage_on [primary]
go
alter table [dbo].[image] with nocheck add
constraint [pk_image] primary key nonclustered
(
[img_pk]
) on [primary]
go
------------------------------------------------------------