如何将图像从loginform上传到mysql数据库 [英] How to upload images from loginform to mysql database

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

问题描述

public void LoadImages()

{

MySqlConnection cn = new MySqlConnection(connstring);

cn.Open();

string image = txtLogo.Text;

byte [] ImageData;

FileStream fs = new FileStream(image,FileMode.Open,FileAccess.Read);

BinaryReader br = new BinaryReader(fs);

ImageData = br.ReadBytes((int)fs.Length);

br.Close();

fs.Close();

MySqlCommand cmd = new MySqlCommand(插入Fn_Pictures(图像,电子邮件)值(@Images,'+ txtEmailId.Text +'),cn);

cmd.Parameters.AddWithValue(@ Images,MySqlDbType.LongBlob).Value = ImageData;

cmd.ExecuteNonQuery();

cn.Close();

}

public void LoadImages()
{
MySqlConnection cn = new MySqlConnection(connstring);
cn.Open();
string image = txtLogo.Text;
byte[] ImageData;
FileStream fs = new FileStream(image, FileMode.Open, FileAccess.Read);
BinaryReader br = new BinaryReader(fs);
ImageData = br.ReadBytes((int)fs.Length);
br.Close();
fs.Close();
MySqlCommand cmd = new MySqlCommand("insert into Fn_Pictures(Images,Email)values(@Images,'"+txtEmailId.Text+"')", cn);
cmd.Parameters.AddWithValue("@Images", MySqlDbType.LongBlob).Value = ImageData;
cmd.ExecuteNonQuery();
cn.Close();
}

推荐答案

这篇关于如何将图像从loginform上传到mysql数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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