fileupload插入第2部分 [英] fileupload insertion part 2

查看:113
本文介绍了fileupload插入第2部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

伙计们,



我的程序使用此代码:

byte [] filedata = Fileupload1.FileBytes;

row [productimg] = filedata;


但是,我的问题是在我的datalist视图下的productimg列中,它刚刚声明System.byte []

如何将其更改为我上传的图片。顺便说一句,在我的产品专栏中,我使用image作为数据类型。

Guys,

My program worked with this code:
byte[] filedata = Fileupload1.FileBytes;
row["productimg"] = filedata;

But, my problem is in my datalist view under the productimg column it's just stated "System.byte[]".
How can I change that into the picture i uploaded. Btw, in my products column i used image as the data type.

推荐答案

正如我上次所说:这是因为你创建SQL命令的方式。您正在连接字符串以形成它,这是您得到的问题之一。 (另一个是你的数据库被删除了,因为世界另一边的人虽然很有趣 - 这被称为SQL注入攻击。)



当我上次说过,请阅读:为什么我得到参数无效。我从数据库中读取图像时出现异常? [ ^ ]它解释了问题和解决方案。它主要关注图像被保存但是当你直接使用字节数组时也会发生完全相同的事情。只有你的数据库中存储了System.Byte []而不是System.Drawing.Bitmap...
As I said last time: it's because of the way you are creating your SQL command. You are concatenating strings to form it, and this is one of the problems you get as a result. (The other is your database being deleted because someone on the other side of the world though it would be funny - this is called an SQL Injection Attack.)

As I said last time, read this: Why do I get a "Parameter is not valid." exception when I read an image from my database?[^] It explains the problem, and the solution. It is mostly concerned with Images being saved but exactly the same thing happens when you use an array of bytes directly as well. Only you get "System.Byte[]" instead of "System.Drawing.Bitmap" stored in your DB...


这篇关于fileupload插入第2部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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