Page 1 of 2

image in the report???

Posted: Mon Dec 01, 2008 11:50 am
by abhi0410
i have image stored in the database....

i am using stored procedure and getting the image and other fields....

But how to show the image in the report....????

+ sometime image wont be present in the database...How to handle that situation?????

Thanks...plz reply soon..





image in the report???

Posted: Mon Dec 01, 2008 12:42 pm
by abhi0410
i am using the stored like this :

ALTER PROCEDURE [dbo].[Company_Details]
AS
Begin
select CompanyName,year,Address1,PhoneNo,Logo
From mstCompany_Detail
End


Here Logo is column name which stores the image....

n error i am getting is when i am use the property Data Column

method[From Stream]
Parameter is not valid...

And when i use image data then i get error:
Cannot convert explicitly byte[] to system.drawing.image.

Plz reply soon...

image in the report???

Posted: Mon Dec 01, 2008 1:04 pm
by abhi0410
Here in this post

http://forum.stimulsoft.com/Default.aspx?g=posts&t=1632


i saw that Picturebox1.Contro.........


Where is this picturebox control.??? n i have jus image control and there is no property called "Control"...

i am using stimulreport 2007.2

Plzz help soon...


image in the report???

Posted: Mon Dec 01, 2008 5:21 pm
by Edward
Hello.

This post described using PictureBox control in the Dialog Form of the report.

for displaying of the images in the report's page you have to use Image component.

This component has DataColumn property. Please assign this property with the DataColumn:

DataSourceName.Logo

Thank you.

image in the report???

Posted: Mon Dec 01, 2008 11:04 pm
by abhi0410
yes i did that i got error......

how to do that?????

image in the report???

Posted: Mon Dec 01, 2008 11:19 pm
by abhi0410
I feel there is some problem in conversion....

in my database i have saved the Logo in the format "image"

i mean the column name is Logo and DataType is image......

and when i execute the stored procedure then i get the datatype for the logo column as byte[]....n even if i change it to "image" type then also i get error.

image in the report???

Posted: Tue Dec 02, 2008 2:42 am
by Edward
Hi, Abhi.

I can assure you that there is no problem in the conversion.

Here is the code for saving image in the database.

Code: Select all

string myConnectionString = "Data Source=.\SqlExpress;Initial Catalog=Northwind;User ID=sa; Password =1"; 
string fileName = "myImage.bmp";
System.IO.FileStream stream  = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
byte[] buf = new byte[stream.Length];
int imageSize = buf.Length;
stream.Read(buf, 0, buf.Length);
Image myImage = Image.FromStream(new System.IO.MemoryStream(buf));
if (stream != null) stream.Close();
SqlConnection myConnection = new SqlConnection(myConnectionString);
SqlCommand storeimage = new SqlCommand("INSERT INTO Categories "
+"(Picture, Description, CategoryName) "
+" values (@image, @description, @categoryname)", myConnection);
storeimage.Parameters.Add("@image", SqlDbType.Image, imageSize).Value = buf;
storeimage.Parameters.Add("@description", SqlDbType.VarChar).Value = imageSize;
storeimage.Parameters.Add("@categoryname", SqlDbType.VarChar).Value = "MyImage3";

myConnection.Open();
storeimage.ExecuteNonQuery();
myConnection.Close();
Please use my instructions above for showing of the image datacolumn in the report.

Thank you.

image in the report???

Posted: Tue Dec 02, 2008 4:15 am
by abhi0410
i did exectly what u said...but still i got this error..

method[From Stream]
Parameter is not valid...


What does this error mean?????

image in the report???

Posted: Tue Dec 02, 2008 7:09 am
by Edward
Please send the mrt template of your report to support[at]stimulsoft.com.

Thank you.

image in the report???

Posted: Tue Dec 02, 2008 11:52 pm
by abhi0410
I have send you the report template.. Please go through and guide me where i am going wrong.

Thanks.