当图像路径存储在数据库中时,如何在图像框中显示图像

编程入门 行业动态 更新时间:2024-10-25 14:22:31
本文介绍了当图像路径存储在数据库中时,如何在图像框中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我遇到问题,在图像框中显示图像。我在桌子上有以下字段用户: 1用户名 2电子邮件 - 主键 3岁 4密码 5 image_name 6 image_path 以及保存图像的文件夹 - User_Pic。 现在,我使用以下代码保存了数据库中的图像名称和路径:

FileUpload。 PostedFile.SaveAs(Server.MapPath( 〜/ User_Pic /)+ FileUpload.FileName.ToString( )); string Filename = Path.GetFileName(FileUpload.PostedFile.FileName); string sql = 插入User_Table值(' + txtUser_Name.Text + ',' + txtEmail_Id.Text + ',' + txtAge.Text + ',' + txtPassword.Text + ',' +文件名+ ',' + User_Pic / +文件名+ '); ob.cmd = new System.Data.SqlClient.SqlCommand(sql,ob.con); ob.cmd.ExecuteNonQuery(); lblInfo.Text = 注册成功;

现在如何使用查询作为电子邮件ID在图像框中显示它:

string sql = 从User_Table中选择Image_Path,其中Email_Id =(' + TextBox1.Text + ');

after this i'我遇到了麻烦? 请帮助

解决方案

使用

picturebox.ImageLocation = your_image_path;

并指定路径!

i''m having a problem, in displaying the image in the imagebox. i''m having the following fields in my table User: 1 user name 2 email- primary key 3 age 4 password 5 image_name 6 image_path and the folder in which the image is saved named - User_Pic. now, i have saved the image name and path in the database using the following code:

FileUpload.PostedFile.SaveAs(Server.MapPath("~/User_Pic/") + FileUpload.FileName.ToString()); string Filename = Path.GetFileName(FileUpload.PostedFile.FileName); string sql = "insert into User_Table values('" + txtUser_Name.Text + "','" + txtEmail_Id.Text + "','" + txtAge.Text + "','" + txtPassword.Text + "','" + Filename + "','" + "User_Pic/"+Filename + "')"; ob.cmd = new System.Data.SqlClient.SqlCommand(sql, ob.con); ob.cmd.ExecuteNonQuery(); lblInfo.Text = "REGISTERED SUCCESSFULLY";

Now how to display it in image box using the query as email id:

string sql = "select Image_Path from User_Table where Email_Id = ('" + TextBox1.Text + "')";

after this i''m having the trouble ?? PLEASE HELP

解决方案

use

picturebox.ImageLocation="your_image_path";

and assign path to it!

更多推荐

当图像路径存储在数据库中时,如何在图像框中显示图像

本文发布于:2023-10-07 10:41:42,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   框中   中时   路径   数据库

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!