473,569 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieving image from DB and to convert byte array value

1 New Member
hi ,
i have problem with Retrieving image from DB
i have a table with image datatype
i store a file by using code as follows
--------------------------------------------------
string strType;
int intLength,intSt atus;
Stream ipStream;
intLength = File1.PostedFil e.ContentLength ;
strType = File1.PostedFil e.ContentType;
byte []imgContent = new byte[intLength];
ipStream = File1.PostedFil e.InputStream;
intStatus = ipStream.Read(i mgContent, 0, intLength);
SqlCommand cmd = new SqlCommand("sp_ insert_image", connection);
cmd.Parameters. Add("@pname", SqlDbType.Image ).Value = imgContent;
cmd.Parameters. Add("@type", SqlDbType.VarCh ar).Value = strType;
cmd.CommandType = CommandType.Sto redProcedure;
connection.Open ();
cmd.ExecuteNonQ uery()
----------------------------------
it inserted into db.

but ,

while reading from db,table value in dataset like as follows

SqlDataAdapter da = new SqlDataAdapter( "select pname,type from img_tab ",con);
DataSet ds = new DataSet();
da.Fill(ds);

pname
---------
System.Byte[] ---------> it doesnt retrieve binary value.
--------------------------------

problem 2
---------------
SqlDataReader dr = cmd.ExecuteRead er();
while (dr.Read())
{
Response.Conten tType = dr["type"].ToString();
Response.Binary Write(dr["pname"]); in this line error
}

Error 2 Argument '1': cannot convert from 'object' to 'byte[]' D:\velu\Image\r eadrealimage.as px.cs 30 34 D:\velu\Image\

Error 1 The best overloaded method match for 'System.Web.Htt pResponse.Binar yWrite(byte[])' has some invalid arguments D:\velu\Image\r eadrealimage.as px.cs 30 13 D:\velu\Image\

so Help me to identify this
Mar 6 '08 #1
0 1819

Sign in to post your reply or Sign up for a free account.

Similar topics

3
11747
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem...
8
4545
by: iyuen | last post by:
I'm having problems with converting a byte array to an image object~ My byte array is an picture in VB6 StdPicture format. I've used propertybag to convert the picture into base64Array format in XML, and embedded the array as some child element in an xml file, i.e.: ...
10
7382
by: John Smith | last post by:
I know that uploading an image to a database has been covered, oh, about 3 trillion times. However, I haven't found anything covering uploading to a MySQL database with .net. Please don't recommend storing the image to the filesystem and only keeping a pointer to that in the table. I want to dump the image to a table. My code dumps the...
2
7883
by: Clas Hortien | last post by:
Hi, i have a array of uint and want to display this array as a System.Web.UI.WebControls.Image. //========================================= uint ar = new uint; string fName;
7
11608
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard is proving to be more difficult. These pictureboxes are bound to an AccessDB. If the user wants to add an image, they select an image using an...
0
2321
by: sebascomeau | last post by:
Hi everyone, Hello my name is Sebastien and I need some help. He have one week past and I search to do one thing but I can't. If someone help me, I'll be so happy :). My problem is I want to upload a file(image), convert this image in an array of byte. Take this array and pass it to a web service. The web service take this array of byte and...
0
1310
by: bertkuiken | last post by:
I'm new to .net and c# but have done this before at j2ee and php. All i want is to post a xml file as a string from an external website and retrieve it from the postdata at my c# programming code. Most of the examples online describe the posting of data at an external website, without the code for the external website or examples where the data...
8
10090
by: anandmms | last post by:
Hello friend, my problem is to save more than one fingerprint images in one byte array and then store in database(oracle). i dont know how to solve it. But previously i had did image saving using byte array, but i want to know how to save more than one images in one database field.... actually i convert one image to byte array using the...
0
10737
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information inside an image, hide your complete image as text ,search for a particular image inside a directory, minimize the size of the image. However this is not...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6287
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3647
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.