在datalist中显示二进制图像 [英] display binary image in datalist

查看:62
本文介绍了在datalist中显示二进制图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在尝试使用where子句在datalist中显示二进制图像,在datalist中只想显示二进制图像的登录人的特定图像。

我尝试做但希望能够显示登录的人的一些图像..

i我正在使用Handler来显示图像以显示登录者的图像。

in处理程序哪些代码我应该没有得到,我应该使用会话..

Hop U guyz wil帮助我。

Hi I am trying to display binary image in datalist with the use of where clause , in datalist want to show binary image only a particular images of the person who logged in .
I try to do but want be able to show a few images of person who is logged in..
i am using Handler to display images to display images of person who is log in.
in handler which code should i apply not getting , should i used session..
Hop U guyz wil Help Me.

推荐答案

你可以提取来自图像数据库的二进制数据,请确保附加正确的文件格式,然后在 img 元素中显示该文件。你应该知道的一件事是文件是二进制形式的,所以你需要以文件的形式编写二进制文件(并附加文件格式),



You can extract the binary data from the database of the image, make sure you append the correct format of the file, and then display the file inside the img element. One thing that you should know, is that the file would be in binary form, so you need to write the binary in the form of a file (and appending the file format too),

Response.ContentType = file.MimeType;
Response.BinaryWrite((byte[])file.FileContent);





以上代码就是这么做的。它将内容类型设置为响应;文件,然后将二进制数据写入响应;因此你的文件。



文章 [ ^ ]您应该有兴趣阅读。本文包含此过程所需的所有代码和说明。您可以添加WHERE子句来仅提取当前用户ID的文件。如下面的代码,





Above code does that. It sets the content type to the response; file, and then writes the binary data to the response; thus your file.

The article[^] that you should be interested in reading. The article contains all of the code and explaination required for this process. You can add a WHERE clause to extract the files for only the current user id. Such as the following code,

SELECT * FROM Images WHERE UserId = 2





或者UserId;可能由参数传递。



非常个人的提示,永远不会将您的文件存储在社交网站的数据中。将有很多用户存储他们的文件,并且数据库的空间非常昂贵;除非您为多个PB的空间购买了SQL Server的Web版本。用户将其数据上传到服务器,并且该空间将在数据库中使用,而应始终将文件存储在文件系统中,并将文件的路径存储到数据库的表中。这将确保数据库的空间不被使用,不应该使用它。



Or what so ever UserId; might be passed by a parameter.

A very personal tip to you, never ever store your files in the data for a social website. There would be a lot of users storing their files, and the space of the database is very expensive; unless you've bought the SQL Server's Web edition for a space of multiple PBs. Users would upload their data to the server, and the space would be used in the database, instead you should always store the files in the file system, and just store the file's path to the database's table. This would ensure that the database's space is not being used where it should not be used.


这篇关于在datalist中显示二进制图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆