我以二进制形式将图像保存在数据库中如何检索以gridview形式在数据库中显示图像 [英] i save the image in database in binary form how i retrieve display it form database in gridview

查看:107
本文介绍了我以二进制形式将图像保存在数据库中如何检索以gridview形式在数据库中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以二进制形式将图像保存在数据库中如何检索以gridview形式在数据库中显示图像

这是我的桌子

i save the image in database in binary form how i retrieve display it form database in gridview

THIS IS MY TABLE

UserId  int
ImageName image



mycode是




mycode is


 if (FileUpload1.HasFile)
        {
            byte[] ImageName = FileUpload1.FileBytes;
            string query = "Insert into Pictures(UserId,ImageName)values(''" + Session["Id"].ToString() + "'',@imagename)";
            SqlConnection conn = new SqlConnection(connstr);
            SqlCommand com = new SqlCommand(query, conn);
            com.Parameters.Add("@imagename", SqlDbType.VarBinary).Value = ImageName;
            conn.Open();
            com.ExecuteNonQuery();
            conn.Close();
}

推荐答案

是答案.
Sergey Chepurin.
Here is the answer.
Sergey Chepurin.


请尝试以下步骤:
1.打开连接
2.使用选择查询准备命令
3.执行命令,获取数据集紧密连接中的数据.
4.将数据集表的字段绑定到网格-一个将是图像字段
Try these steps:
1. Open connection
2. Prepare a command with a select query
3. Execute command, get data in a dataset close connection.
4. Bind the fields of dataset table to the grid - one would be image field


这篇关于我以二进制形式将图像保存在数据库中如何检索以gridview形式在数据库中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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