image in the report???

Stimulsoft Reports.NET discussion
abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post 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..




abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post 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...
abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post 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...

Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

image in the report???

Post 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.
abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post by abhi0410 »

yes i did that i got error......

how to do that?????
abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post 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.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

image in the report???

Post 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.
abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post 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?????
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

image in the report???

Post by Edward »

Please send the mrt template of your report to support[at]stimulsoft.com.

Thank you.
abhi0410
Posts: 47
Joined: Fri Sep 26, 2008 12:42 pm
Location: bombay

image in the report???

Post by abhi0410 »

I have send you the report template.. Please go through and guide me where i am going wrong.

Thanks.
Post Reply