如何存储&使用asp.net c#在mysql数据库中检索图像 [英] How to store & retrieve images in mysql database using asp.net c#

查看:104
本文介绍了如何存储&使用asp.net c#在mysql数据库中检索图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...



Plz帮助我,紧急。



如何存储图像在mysql db中,检索它们吗?。



谢谢你。





任何有,我有解决方案。

谢谢你。

Hi...

Plz help me,its urgent.

How to store images in mysql db,retrieve them ?.

thank u.


Any have, i got solution to it.
Thank u.

推荐答案

这个是什么Google返回。



我特别喜欢这个结果



PS帮自己一个忙。你不应该在这里等待答案,而应该先看看,然后你应该自己尝试一下。如果你遇到困难,这里的人很乐意帮助你。

但是期待别人为你做的一切都是粗鲁和懒惰。



祝你好运!
This is what Google returns.

I particularly like this result.

P.S. Do yourself a favor. Instead of waiting here for an answer you should look around first, then you should try something on your own. If you get stuck nice people here will gladly help you.
But expecting for others to do all work for you is kind of rude and lazy.

Good luck with your assignment!


试试吧!!解决了一个!!



Try this !! Solved one !!

protected void Button1_Click(object sender, EventArgs e)
{
    string FileName = Path.GetFileName(FileUpload1.PostedFile.FileName);
    string SaveLocation = Server.MapPath("Folder name of which image is stored") + "\\" + FileName;

    try
    {

        FileUpload1.PostedFile.SaveAs(SaveLocation);

        string strQuery = "Insert Into Elevation (Field_name1, Field_name2)" + " values(@Project, @Elevation)";

        SqlCommand cmd = new SqlCommand(strQuery);

        cmd.Parameters.AddWithValue("@Field_name1", TextBox1.Text);

        cmd.Parameters.AddWithValue("@Field_name12", "Folder name/" + FileName);

        cmd.CommandType = CommandType.Text;

        cmd.Connection = Con;

        Con.Open();

        cmd.ExecuteNonQuery();

    }

    catch (Exception ex)
    {

        Response.Write("Error:" + ex.Message);

    }

    finally
    {

        Con.Close();

        Con.Dispose();

    }
}





如果有效,请将其标记为答案!!



Mark it as answer if it works !!


这篇关于如何存储&使用asp.net c#在mysql数据库中检索图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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