Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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.
Posted

1 solution

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...
 
Share this answer
 
Comments
Ron Beyer 8-Oct-13 14:35pm    
+5'd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900