Wednesday, March 28, 2012

Images From Sql Database

I have a database in sql server with a table containing a few images stored as binary data and there unique ids. From a Visual Basic.NET Application I want to use the crystal report to display 1 of the images based on the id that it is fed. How can I read and image from the sql database and display it in a Crystal Report? Any help offered is greatly appreciated.I've used a stored procedure to get the images from db and then add the blob field to the report. problem is that the wizard "enter parameter value" keeps prompting while you're going to drag the blob to your report. I still haven't find a solution for this problem.|||Just drag the blob column to report and go to preview mode and check if it is displaying the image|||I too have the same problem But in the case of Auto cad images(*.dwg)

I am saving the image in image field (SQL server) in binary format

Is there any solution for that?

Reply as much as earlier!|||What is the error you get?|||While adding the image field(SQL server) in crystal report,it doesn't showing any error

But

1.If the image format other than autocad(*.dwg) then it is showing the image as it is.

2.But in the case of autocad image it doesn't showing anything the field space would be blank.

If anyone guide me for this prob,please help me out

My project has been delayed because of this problem

Lingeswaran.r|||Hi all
I have some problem load image to Crytal Report 11

I have database from sql Server. The Columns Images after.
The column
Column name Data Type Length Allownulls
Picture varchar 50 *

After i save to database is

image\picture.jpg.

When i drag the column to Crystal Report 11 it have only is image\picture.jpg.
Can you help me ?
Display the picture.jpg is a picture
Thank you.|||Hi,
I had face the problem in Sql server with CrystalReports11 at Visual studio2005. By doing the following way you can solve the problem.

Let assume table "Item_t" having "ItemPicture'' column and its datatype is "Image'' and assume picture is stored in that table.

fecth the picture data to a datatable.

Let assume the picture is in dtItem & write the following method

private DataTable ConvertPicture(DataTable dtItem)
{
DataTable dtReturn = dtItem.Clone();

foreach (DataRow dRow in dtItem.Rows)
{
DataRow drRow = dtReturn.NewRow();

// Convert the picture into binary format

Byte[] bPictureInByte = (Byte[])dtItem.Row["ItemPicture''];
System.IO.MemoryStream mStream = new System.IO.MemoryStream(bPictureInByte ); // convert as stream
Bitmap pictureBimap= new Bitmap(mStream);//store in a Bitmap

// save the picture data in Local harddisk as .jpg file
pictureBimap.Save("C:\\temp\\Itempicture.Jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

//Read the same jpg Picture from your Local harddisk
System.IO.FileStream fs = new System.IO.FileStream("C:\\temp\\Itempicture.Jpg", System.IO.FileMode.Open);
System.IO.BinaryReader br = new System.IO.BinaryReader(fs);

//convert to byte[] & save in your new data row
drRow = br.ReadBytes((int)br.BaseStream.Length);
br.Close();

//add the datarow to the datatable dtReturn;

dtReturn.Rows.add(drRow);

}

return dtReturn

}

now you passing the dtReturn data table to your .rpt file and print the Image.

Best wishes|||But now i don't want to Write a picture into the SQL Server
I only want write a link of it.
Example: image\picture_name.jpg
After that i load into Crytal Report.
How I can to do it ?
You can help me ?

If i write to sql server is no proplem.|||Hi all,
I want to display image in report but I can't. The following is what I do.
I create a report in C#.NET 2003, using CR XI. Data is stored in SQL Server 2005, and I store image as BLOB field. I design by drag and drop fields into report. In my code, I connect to database, get mydataset by executing a sql string, and then using rpt.SetDataSource(mydataset). All data in text field is ok but image field is empty.
Anybody help me, please.|||I know why I can't display image in report now. A simple reason is the aslias name of image field in sql statement and the image field name in my report are different.

But now I don't understand the reason why sometimes I can 't drag image field from tree view into report. Anybody know?

No comments:

Post a Comment