如何将图像控件中的图像发送到SQL数据库 [英] How do I send an image in an image control to a SQL Database

查看:83
本文介绍了如何将图像控件中的图像发送到SQL数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

美好的一天同事们,



我可以使用fileUpload控件将图像保存到数据库。但我的问题是如何将图像控件中的图像保存到数据库。



我想要的方式是,当用户向数据库插入新帖子时,将在用户个人资料中显示带有图像控件的图片到我的数据库中的pic栏。



请有人帮助我。



谢谢。

Good day fellow programmers,

Please i can save image to database using the fileUpload control. But my problem is how do i save image in an image control to database.

I want it in a way that when a user is inserting a new post to the database, the pic being displayed with an image control in the user profile will be sent to the pic column in my database.

Please can someone help me out.

Thanks.

推荐答案

你见过这个 [ ^ ]文章?它几乎涵盖了你需要的一切。
Have you seen this[^] article? It pretty much covers everything you need.


你好felix,



有很多文章在网上甚至是关于这个问题代码项目,请看以下链接,这可能会对你有所帮助。



如何从sql server中检索图像 [ ^ ]
Hi felix,

there are many articles related this question on web or even on code project, look at the following link, this may help you.

How to retrive an image from sql server[^]


在.cs文件用于上传文件并保存到您可以检索它的特定位置



if(FileUpload1.HasFile)

{

string filename = TitleBox.Text +(maxid + 1).ToString()+ FileUpload1.FileName;

FileUpload1.SaveAs(Server.MapPath(〜/ ListingImages / ).ToString()+ filename);

path =http:// ouron lineneeds.com/ListingImages/+ filename;

}





要显示图像,请使用字符串< br $>


字符串查询=SELECT标题,徽标,描述,地址,用户名,PhoneNo,MobileNo,EmailID,网站,已确认,关键字来自分类WHERE ListID ='+ ListId +';

DataSet ds = Query.Select(query);
use this in .cs file for the file uploading and saving into the specific location from where you can retrieve it

if (FileUpload1.HasFile)
{
string filename = TitleBox.Text + (maxid + 1).ToString() + FileUpload1.FileName;
FileUpload1.SaveAs(Server.MapPath("~/ListingImages/").ToString() + filename);
path = "http://ouronlineneeds.com/ListingImages/" + filename;
}


To show an image use string

string query = "SELECT Title,Logo,Descript,Address,UserName,PhoneNo,MobileNo,EmailID,Website,Confirmed,Keywords FROM Classified WHERE ListID='" + ListId + "'";
DataSet ds = Query.Select(query);


这篇关于如何将图像控件中的图像发送到SQL数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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