从SQL数据库检索图像期间发生错误 [英] Error occured during retreive image from SQL database

查看:82
本文介绍了从SQL数据库检索图像期间发生错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

现在我想从数据库中检索图像并将其显示在picturebox上.
我花了更多时间,但发生了一个错误参数无效".在这里我怎么
克服这个错误.欢迎所有回复.

在此先感谢
Dhinesh kumar.V

Dear All,

Now i wanna to retrieve image from database and display that at picturebox.
I spend more time but an error occured "Parameter is not valid". Here how can i
overcome this error. All replies welcome.

Thanks in Advance
Dhinesh kumar.V

private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = (@"Data Source=EUNIK-705F2C195\SQLEXPRESS;Initial Catalog=images;User ID=sa;Password=fintransys");
            con.Open();
                     
             SqlCommand _sqlcommand = new SqlCommand("select Images from imagestore where ImageID='" + txt_EnterID.Text + "'", con);
            SqlDataAdapter _sqldataadapter = new SqlDataAdapter(_sqlcommand);
            DataSet _dataset = new DataSet();
            DataTable _dataTable = new DataTable();
            _sqldataadapter.Fill(_dataset,"imagestore");
            int c = _dataset.Tables["imagestore"].Rows.Count;

            if(c>0)
            {
                Byte[] _Byte = new Byte[0];
                _Byte = (Byte[])(_dataset.Tables["imagestore"].Rows[c - 1]["Images"]);
                MemoryStream _Memorystream = new MemoryStream(_Byte);
                pictureBox1.Image = Image.FromStream(_Memorystream);
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                pictureBox1.Refresh();
            }
            con.Close();
        }




在此TableName-> imagestore ColumnName-> Images

Enhzflep:将代码从注释复制到原始问题




Here TableName-> imagestore ColumnName->Images

Enhzflep: code copied from comments to original question

推荐答案

[
Does this[^] or this[^] help?


这篇关于从SQL数据库检索图像期间发生错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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