gpt4 book ai didi

c# - 如何从mysql数据库中检索图像?

转载 作者:行者123 更新时间:2023-11-30 00:19:39 26 4
gpt4 key购买 nike

我已经使用以下方法将图像存储到 mysql 中,现在我想检索...我想将 ny 图像从字节转换为图像,然后显示它...我该怎么做

public void LoadImages()
{
byte[] ImageData;
string image = txtLogo.Text;
FileStream fs = new FileStream(image, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
ImageData = BitConverter.GetBytes(fs.Length);
string query = "insert into Fn_Pictures(Images,Email)values(@Images,'" + txtEmailId.Text + "')";
MySqlConnection con = new MySqlConnection(connstring);
MySqlCommand cmd = new MySqlCommand(query, con);
MySqlDataReader myReaeder;
con.Open();
myReaeder = cmd.ExecuteReader();

}

最佳答案

将图像存储在数据库中是一个完整的开销。只需将它们保存在磁盘上即可,速度要快得多。

如果您想使用 blob 来存储它们,那么您将需要一个不同的图像页面,并使用正确的标题来显示它。

关于c# - 如何从mysql数据库中检索图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23337019/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com