使用ASP.NET在SQL Server 2008中保存图像 [英] Image saving in sql server 2008 with asp.net
问题描述
亲爱的朋友,
我有关于将图像保存到sql server 2008数据库表列中的问题.
当我通过asp.net中的文件上传器控件将图像上传到数据库时,我必须遵循什么过程才能将图像保存到数据库中,然后单击提交"按钮,我试图获取文件的详细信息并进行转换将其转换为字节格式以便将其存储到数据库中,但是我无法从中获取任何信息.
由于我的整个表单都保存在更新面板中,因此无论何时在某个控件上发生回发事件,文件上载程序控件中的路径都会被清除,因此我无法将其保存到文件中.请让我知道是否还有其他方法.
谢谢与问候
Varun Sareen
Dear Friends,
I have a problem regarding saving the image into sql server 2008 database table column.
what process i have to follow in order to save the image into database as when i am uploading the image through the file uploader control in asp.net then on the click of the submit button i am trying to fetch the details of the file and converting it into the bytes format in order to store it into the DB but i am not able to get anything from it.
As my whole form is kept in an update panel so when ever a postback event occurs on some control the path in the file uploader control gets cleared and so i am not able to save the same into the file. Please let me know if there is some other way around.
Thanks & Regards
Varun Sareen
推荐答案
以下链接肯定会帮助您-
http://www.dotnetcurry.com/ShowArticle.aspx?ID=129 [ ^ ]
http://csharpdotnetfreak.blogspot.com/2009/07/fileupload-control- save-images-database.html [ ^ ]
http://www.aspnettutorials.com/tutorials/database/Save-Img-ToDB- Csharp.aspx [ ^ ]
将图像保存到SQL Server 2000数据库 [ http://odetocode.com/articles/163.aspx [
The following links should surely help you out -
http://www.dotnetcurry.com/ShowArticle.aspx?ID=129[^]
http://csharpdotnetfreak.blogspot.com/2009/07/fileupload-control-save-images-database.html[^]
http://www.aspnettutorials.com/tutorials/database/Save-Img-ToDB-Csharp.aspx[^]
Save An Image Into SQL Server 2000 Database[^]
http://odetocode.com/articles/163.aspx[^]
http://www.databasejournal.com/features/mssql/article. php/3724556/Storing-Images-and-BLOB-files-in-SQL-Server-Part-2.htm [ http://chiragrdarji.wordpress.com/2007/03 /05/storing-and-retrieving-image-in-sql-server/ [
http://www.databasejournal.com/features/mssql/article.php/3724556/Storing-Images-and-BLOB-files-in-SQL-Server-Part-2.htm[^]
http://chiragrdarji.wordpress.com/2007/03/05/storing-and-retrieving-image-in-sql-server/[^]
只是一个建议,请使用varchar
作为表列,然后只需将图像的路径保存到服务器即可,而不是转换为字节.
问候,
爱德华
Just a suggestion, usevarchar
as your table column then instead of converting to bytes, you just need to save the path of the image to your server.
Regards,
Eduard
这篇关于使用ASP.NET在SQL Server 2008中保存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!