参数值无效。从数据库加载图像 [英] the parameter value is not valid. in loading image from data base

查看:183
本文介绍了参数值无效。从数据库加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨bax

i从sqlserver2088 r2加载图片有问题请帮帮我

我的代码有这个错误:参数值无效。



我的代码:



hi bax
i have problem in loading an image from sqlserver2088 r2 please help me
my code has this error : the parameter value is not valid.

its my code:

string pic = "select PIC from _TRBS_PIC WHERE SERIAL = '" + fieldTxt1.Text + "';
SqlDataAdapter sda = new SqlDataAdapter(pic, sqlCnn);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows.Count>0)
{
    byte[] imageBytes = new byte[0];
    imageBytes = (byte[])dt.Rows[0][0];
    MemoryStream ms = new MemoryStream(imageBytes);
    picBoxUser.Image = Image.FromStream(ms); // the parameter value is not valid
}

推荐答案

这可能是你在第一时间存储数据的方式。 看这里: 为什么我会得到一个参数是无效。我从数据库中读取图像时出现异常? [ ^ ]
It's probably how you stored the data in the first place. See here: Why do I get a "Parameter is not valid." exception when I read an image from my database?[^]


这篇关于参数值无效。从数据库加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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