Quote:
quote:But I am using this method of storing the path
So I would like to store actual image in database
& how yo use image datatype if u can please tell me.
|
Perhaps you didn't understand me the first time.
You really don't want to do this.
Images stored as the image datatype make the database large and bloated. The image data itself is stored in a manner that makes it slow and inefficient. It is difficult to maintain images; if you need to update the image, the only way is via client code - storing the path instead means all you have to do is replace the image file with another and the new image is instantly available. There is no good way to stream an image into a web page, since the source of an HTTP image must be from a URL.
All in all, IMO it's just a bad idea to do this. So I guess I have a bit of a philosophical problem advising you how to do something that I have very strong feelings against doing. (Besides, since I think it's such a wrong way to do something, it's been a long time since I wrote any code to handle the situation and I'm not sure I remember how to do it :D).
The code is something like this. You can define a stored procedure parameter to be of image datatype and use it to INSERT or UPDATE an image column. Thus:
CREATE PROCEDURE updateimage
@SomeIDvalue integer
@Image image
AS
UPDATE yourtable
SET imagecolumn=@image
WHERE keyIDcolumn=@SomeIDvalue;
If you use ADO in your client code, define the parameter as type adVarBinary with a length of 2147483647 (maximum integer value). You construct the image data as a variant and set it as the value of the parameter.
To read image data from the database, you cannot use the image datatype as an output parameter; instead you must either open a recordset and retrieve the image as a field in the recordset then convert it to a byte array, or use the ability for a command object to place its result into a stream object directly via the adExecuteStream execute option.
Good luck. And don't say you weren't warned.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com