Showing posts with label stored. Show all posts
Showing posts with label stored. Show all posts

Wednesday, March 28, 2012

Images not displaying on reports!

We are trying to create a Report w/ images that are stored in the SQL Server table.

These images are being copied and pasted into an ACCESS application (w/, as said above, a SQL Server back-end)....

All I get on the report is a box with a red 'X'.

(Now, I have tried the routine to remove the OLE header as suggested on other places on the Internet. While this works for the Northwind images, this is not working on our images. Which leads me to guess that the OLE Header on our images may be different than 78. But how do we know or calculate that?)..

My guess would be that some other people have encountered similar problems.

Any help will be highly appreciated.

Thanks..

Were you able to find the solution for this?

I'm encountering the same problem.

Thanks!

sql

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?

Monday, March 26, 2012

Images

I have a customer that has several thousand images (bmp) stored in a SQL 2000
database. Is there any way to copy the images programmatically to a folder so
they can be viewed using a photo program? Currently they use an Access form
to display the photos and, needless to say, I don't want to copy and paste
4,000 images.
"Paco" <paco6945@.yahooNoSpam.com> wrote in message
news:24B4FEEE-09C8-47E4-AD53-4F51F00DD284@.microsoft.com...
>I have a customer that has several thousand images (bmp) stored in a SQL
>2000
> database. Is there any way to copy the images programmatically to a folder
> so
> they can be viewed using a photo program? Currently they use an Access
> form
> to display the photos and, needless to say, I don't want to copy and paste
> 4,000 images.
>
It's straightforward to do this using a .NET program. When you select rows
from the table you can retrieve the image column as a byte array and save
each byte array to a file.
David

Images

I have a customer that has several thousand images (bmp) stored in a SQL 200
0
database. Is there any way to copy the images programmatically to a folder s
o
they can be viewed using a photo program? Currently they use an Access form
to display the photos and, needless to say, I don't want to copy and paste
4,000 images."Paco" <paco6945@.yahooNoSpam.com> wrote in message
news:24B4FEEE-09C8-47E4-AD53-4F51F00DD284@.microsoft.com...
>I have a customer that has several thousand images (bmp) stored in a SQL
>2000
> database. Is there any way to copy the images programmatically to a folder
> so
> they can be viewed using a photo program? Currently they use an Access
> form
> to display the photos and, needless to say, I don't want to copy and paste
> 4,000 images.
>
It's straightforward to do this using a .NET program. When you select rows
from the table you can retrieve the image column as a byte array and save
each byte array to a file.
Davidsql

Images

I have a customer that has several thousand images (bmp) stored in a SQL 2000
database. Is there any way to copy the images programmatically to a folder so
they can be viewed using a photo program? Currently they use an Access form
to display the photos and, needless to say, I don't want to copy and paste
4,000 images."Paco" <paco6945@.yahooNoSpam.com> wrote in message
news:24B4FEEE-09C8-47E4-AD53-4F51F00DD284@.microsoft.com...
>I have a customer that has several thousand images (bmp) stored in a SQL
>2000
> database. Is there any way to copy the images programmatically to a folder
> so
> they can be viewed using a photo program? Currently they use an Access
> form
> to display the photos and, needless to say, I don't want to copy and paste
> 4,000 images.
>
It's straightforward to do this using a .NET program. When you select rows
from the table you can retrieve the image column as a byte array and save
each byte array to a file.
David

Image to Varchar

Hi All,
I have a small doubt.
How to convert an Imaage of about 110 character length to varchar.
The image is nothing but the text data stored in that format.
While using "convert" function for smaller data,Image to Varchar and
Varchar to Image conversion is successful.
But, here the image is too lengthy.
Kindly, anyone suggest a way.
Thanks,
Dutt.
Dutt
declare @.b binary(4), @.str varchar(255)
select @.b = 3455643
exec master..xp_varbintohexstr @.b, @.str out
print @.str
select cast(cast(cast(0x41 as nvarchar) as varbinary)as varchar)
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegro ups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>
|||> But, here the image is too lengthy.
What do you mean by 'too lengthy'?
Try:
SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
FROM dbo.MyTable
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegro ups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>
|||Hi Dan,
I'm getting some output with that.Even,I have tried it earlier.
But the problem is that the image is being converted into ANSII code,I
suppose.
I'm not getting the actual text.
Thanks
Dutt.
Dan Guzman wrote:[vbcol=seagreen]
> What do you mean by 'too lengthy'?
> Try:
> SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
> FROM dbo.MyTable
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Dutt" <Mr.Dutt@.gmail.com> wrote in message
> news:1167893950.543251.130570@.31g2000cwt.googlegro ups.com...
|||> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
How is the text encoded? I would expect that the data would be converted
according to your database default collation. Can you post a raw data
sample (e.g. 0x68656c6c6f) along with your expected results (e.g. 'hello')?
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167970260.405637.12700@.11g2000cwr.googlegrou ps.com...
> Hi Dan,
> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
> Thanks
> Dutt.
> Dan Guzman wrote:
>

Image to Varchar

Hi All,
I have a small doubt.
How to convert an Imaage of about 110 character length to varchar.
The image is nothing but the text data stored in that format.
While using "convert" function for smaller data,Image to Varchar and
Varchar to Image conversion is successful.
But, here the image is too lengthy.
Kindly, anyone suggest a way.
Thanks,
Dutt.Dutt
declare @.b binary(4), @.str varchar(255)
select @.b = 3455643
exec master..xp_varbintohexstr @.b, @.str out
print @.str
select cast(cast(cast(0x41 as nvarchar) as varbinary)as varchar)
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>|||> But, here the image is too lengthy.
What do you mean by 'too lengthy'?
Try:
SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
FROM dbo.MyTable
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>|||Hi Dan,
I'm getting some output with that.Even,I have tried it earlier.
But the problem is that the image is being converted into ANSII code,I
suppose.
I'm not getting the actual text.
Thanks
Dutt.
Dan Guzman wrote:[vbcol=seagreen]
> What do you mean by 'too lengthy'?
> Try:
> SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
> FROM dbo.MyTable
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Dutt" <Mr.Dutt@.gmail.com> wrote in message
> news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...|||> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
How is the text encoded? I would expect that the data would be converted
according to your database default collation. Can you post a raw data
sample (e.g. 0x68656c6c6f) along with your expected results (e.g. 'hello')?
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167970260.405637.12700@.11g2000cwr.googlegroups.com...
> Hi Dan,
> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
> Thanks
> Dutt.
> Dan Guzman wrote:
>sql

Image to Varchar

Hi All,
I have a small doubt.
How to convert an Imaage of about 110 character length to varchar.
The image is nothing but the text data stored in that format.
While using "convert" function for smaller data,Image to Varchar and
Varchar to Image conversion is successful.
But, here the image is too lengthy.
Kindly, anyone suggest a way.
Thanks,
Dutt.Dutt
declare @.b binary(4), @.str varchar(255)
select @.b = 3455643
exec master..xp_varbintohexstr @.b, @.str out
print @.str
select cast(cast(cast(0x41 as nvarchar) as varbinary)as varchar)
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>|||> But, here the image is too lengthy.
What do you mean by 'too lengthy'?
Try:
SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
FROM dbo.MyTable
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...
> Hi All,
> I have a small doubt.
> How to convert an Imaage of about 110 character length to varchar.
> The image is nothing but the text data stored in that format.
> While using "convert" function for smaller data,Image to Varchar and
> Varchar to Image conversion is successful.
> But, here the image is too lengthy.
> Kindly, anyone suggest a way.
> Thanks,
> Dutt.
>|||Hi Dan,
I'm getting some output with that.Even,I have tried it earlier.
But the problem is that the image is being converted into ANSII code,I
suppose.
I'm not getting the actual text.
Thanks
Dutt.
Dan Guzman wrote:
> > But, here the image is too lengthy.
> What do you mean by 'too lengthy'?
> Try:
> SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
> FROM dbo.MyTable
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Dutt" <Mr.Dutt@.gmail.com> wrote in message
> news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...
> > Hi All,
> > I have a small doubt.
> > How to convert an Imaage of about 110 character length to varchar.
> > The image is nothing but the text data stored in that format.
> > While using "convert" function for smaller data,Image to Varchar and
> > Varchar to Image conversion is successful.
> > But, here the image is too lengthy.
> > Kindly, anyone suggest a way.
> > Thanks,
> > Dutt.
> >|||> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
How is the text encoded? I would expect that the data would be converted
according to your database default collation. Can you post a raw data
sample (e.g. 0x68656c6c6f) along with your expected results (e.g. 'hello')?
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Dutt" <Mr.Dutt@.gmail.com> wrote in message
news:1167970260.405637.12700@.11g2000cwr.googlegroups.com...
> Hi Dan,
> I'm getting some output with that.Even,I have tried it earlier.
> But the problem is that the image is being converted into ANSII code,I
> suppose.
> I'm not getting the actual text.
> Thanks
> Dutt.
> Dan Guzman wrote:
>> > But, here the image is too lengthy.
>> What do you mean by 'too lengthy'?
>> Try:
>> SELECT CAST(SUBSTRING(MyImageColumn, 1, 110) AS varchar(110))
>> FROM dbo.MyTable
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "Dutt" <Mr.Dutt@.gmail.com> wrote in message
>> news:1167893950.543251.130570@.31g2000cwt.googlegroups.com...
>> > Hi All,
>> > I have a small doubt.
>> > How to convert an Imaage of about 110 character length to varchar.
>> > The image is nothing but the text data stored in that format.
>> > While using "convert" function for smaller data,Image to Varchar and
>> > Varchar to Image conversion is successful.
>> > But, here the image is too lengthy.
>> > Kindly, anyone suggest a way.
>> > Thanks,
>> > Dutt.
>> >
>

Image size

I have a SQL database that stores image files (pdf, doc, tif etc). Is it
possible to write a query that shows the size of the file being stored ?
Any help would be great.
Thanks
SiYou can get the bytes used with DATALENGTH -
SELECT DATALENGTH(YourImageColumn)
FROM YourTable
You can find more information on DATALENGTH in Books Online.
-Sue
On Mon, 31 Jul 2006 08:36:01 -0700, Simon
<Simon@.discussions.microsoft.com> wrote:
>I have a SQL database that stores image files (pdf, doc, tif etc). Is it
>possible to write a query that shows the size of the file being stored ?
>Any help would be great.
>Thanks
>Si

Image size

I have a SQL database that stores image files (pdf, doc, tif etc). Is it
possible to write a query that shows the size of the file being stored ?
Any help would be great.
Thanks
SiYou can get the bytes used with DATALENGTH -
SELECT DATALENGTH(YourImageColumn)
FROM YourTable
You can find more information on DATALENGTH in Books Online.
-Sue
On Mon, 31 Jul 2006 08:36:01 -0700, Simon
<Simon@.discussions.microsoft.com> wrote:

>I have a SQL database that stores image files (pdf, doc, tif etc). Is it
>possible to write a query that shows the size of the file being stored ?
>Any help would be great.
>Thanks
>Si

Friday, March 23, 2012

Image Retrieving from database

hi,

I have a SQL database that has Images stored. I am able to read the image from the database and display it. But i am not able to control the size and the position where it is displayed. I want to develop something like a photo album. the images should be displayed in a smaller size. but when the user clicks on the image, it should blow up to its original size.
I am struggling with this for some time. Any suggestions as how to develop it??.
Any help in this regard would be highly appreciated.

thanks,
-sriramCreate thumbnails of the images when they're uploaded.|||Or when they are retrieved.|||You could try streaming the file and resizing it on the fly with GDI+

or using HTTP Handlers:

a good article is at
http://www.c-sharpcorner.com/Code/2003/June/HTTPHandlersForImages.asp

alternatively:

the following code allows an .aspx file to receive parameters (file name and width of picture) and return a .jpg so that in you HTML code you can use access an image like this:

src="SmartPicture.aspx?f=yourpic.jpg&w=50"

and the file yourpic.jpg will be displayed with a width of 50 pixels and a calculated proportional height. The file size will also be reduced - ie: if your original picture was 4Mb, it would be scaled down to around 15kb.

code as follows:

save it as SmartPicture.aspx


<%@. Page Language="C#" %>
<%@. Import Namespace="System.Drawing" %>
<%@. Import Namespace="System.Drawing.Imaging" %>
<script runat="server"
void Page_Load(Object s, EventArgs e) {

double photoWidth,photoHeight;
double percentageDifference = 0;
bool heHasAccess = false;
System.Drawing.Image inputImage;

//get information being sent
heHasAccess = true;

//get file name
string pictureFileName = Request.QueryString["f"];
if(pictureFileName == null || pictureFileName == "") {
heHasAccess = false;
}

//get width
try {
if (Request.QueryString["w"] == null) {
photoWidth = 0;
} else {
photoWidth = Int32.Parse(Request.QueryString["w"]);
}
}
catch {
photoWidth = 0;
}

//if anything went wrong, show error picture
if(!heHasAccess) {
inputImage = System.Drawing.Image.FromFile(Server.MapPath("images/pictureNoAccess.jpg"));
} else {
inputImage = System.Drawing.Image.FromFile(Server.MapPath("images/" + pictureFileName));
}

//if no width was given, assume the default now
if(photoWidth==0) {
if(!heHasAccess) {
photoWidth = 100;
} else {
photoWidth = inputImage.Width;
}
}

//define size for new image
percentageDifference = inputImage.Width / photoWidth;
photoHeight = inputImage.Height / percentageDifference;

//output new image with different size
Bitmap outputBitMap = new Bitmap(inputImage,Convert.ToInt32(photoWidth),Convert.ToInt32(photoHeight));
Response.ContentType = "image/jpeg";
outputBitMap.Save(Response.OutputStream, ImageFormat.Jpeg);

}
</script>

|||This works fine.

But i have the image in a SQL database. I have image in a binary format.

So i am using the Response.BinaryWrite method.

But i have some other infromation also to be dispalyed with the image. For example some descrption and other deatils. But the image gets displayed at the top left corner hiding all other literals and labeles.

Any suggestions please.

thanks,
-sriram|||Could you post the code you are using?|||On button click: I am retreiving an image name :Test1 from my Sql Server database.
I am posting the code:

Dim imgid As String = Request.QueryString("Test1")
Dim conn As String = "data source=ERB112SERV;initial catalog=TEST;persist security info=False;user id=artak;password=po4d8dor1ju;workstation id=ERB112SERV;packet size=4096"

Dim myConnection As New SqlConnection("data source=ERB112SERV;initial catalog=TEST;persist security info=False;user id=artak;password=po4d8dor1ju;workstation id=ERB112SERV;packet size=4096")

Dim sql As String = "SELECT imgdata, imgtype FROM ImageStore WHERE imgtitle = 'Test1'"
Dim command As SqlCommand = New SqlCommand(sql, myConnection)
myConnection.Open()
Dim dr As SqlDataReader = Command.ExecuteReader()
If (dr.Read()) Then

Response.ContentType = dr("imgtype").ToString()
Response.BinaryWrite(dr.Item("imgdata"))

End If
myConnection.Close()

Thanks for mailing.

-sriram|||But the image gets displayed at the top left corner hiding all other literals and labeles.

Sounds like you're mixing absolute, and relative positioning, no?

If thatis the case, then you're going to have to either specify the positioning for the image, or go to all relative positioning (flow layout) for the controls involved.|||You have to assing the image to img tag, then you could display it where ever you want!

Below example might helps you to understand it!

Live example
http://www.w3coder.com/contest/examples/showipinimage.aspx

and code for it at
http://www.w3coder.com/contest/examples/ImageIPonaspxpage.zip

Hope these helps!|||hi,

Sorry. I didnt quiet get it. I am not even able to assign the image from a database.

So i am not able to write the output from a database to an Image.

I am not able to get the idea of assigning relative positioning.

can you help me with a sample codr or so so that i can understand it well.

thanks,
-sriram|||Would you have code for saving an image to a database?|||I don't understand your question.|||

can anyone pls enlighten my on to retrieve the image file from MS Access?

what is the syntax and the way of approving and maybe a sample code.. im a noob... thanks

sql

image question

hello friends

I want to specify a field to save icons I want to give this field a maximum
of 120kb for each icon to be stored in the db.

what datatype should I assign to this field and how do I specify the size ?

Thanks
Tom"Tom" <tomgaomail@.optushome.com.au> wrote in message
news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
> hello friends
> I want to specify a field to save icons I want to give this field a
> maximum
> of 120kb for each icon to be stored in the db.
> what datatype should I assign to this field and how do I specify the size
> ?
> Thanks
> Tom

The image data type is the one used for large binary data, but you can't
specify a size - 2GB is the maximum allowed. Another common approach is to
leave the binary files in the filesystem, and simply store the path to the
file in a varchar column.

Simon|||I considered that option.. however storing path is not the ideal option as
many users may have the same image or icon thus resulting the same image
being sent to all users when the image are suppose to be different as the
image gets overridden when they're the same file name

any other ideas ?
thanks
Tom

"Simon Hayes" <sql@.hayes.ch> wrote in message
news:415175e2$1_2@.news.bluewin.ch...
> "Tom" <tomgaomail@.optushome.com.au> wrote in message
> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
> > hello friends
> > I want to specify a field to save icons I want to give this field a
> > maximum
> > of 120kb for each icon to be stored in the db.
> > what datatype should I assign to this field and how do I specify the
size
> > ?
> > Thanks
> > Tom
> The image data type is the one used for large binary data, but you can't
> specify a size - 2GB is the maximum allowed. Another common approach is to
> leave the binary files in the filesystem, and simply store the path to the
> file in a varchar column.
> Simon|||"Tom" <tomgaomail@.optushome.com.au> wrote in message
news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
>I considered that option.. however storing path is not the ideal option as
> many users may have the same image or icon thus resulting the same image
> being sent to all users when the image are suppose to be different as the
> image gets overridden when they're the same file name
> any other ideas ?
> thanks
> Tom

<snip
Not really - those are pretty much the two options you have. Either use the
image data type and store the file in the database, or leave it in the
filesystem and store the path. It comes down to which approach is easier for
you, given your application and development environment.

Personally I'd go for the path, since then changing a user's icon just means
updating a single column, instead of loading the whole file into the
database. Also, any default or common icons only have to be stored once,
rather than maintaining a separate copy for each user.

You should also check out "Managing ntext, text, and image Data" in Books
Online, which covers the details of working with image data, and there's a
code sample for ADO, if that's what you're using.

Simon|||I had a similar problem where i wanted people to store files on my web
server, because i was worried about file name clashes i was considering
storing them in the database. Instead I came up with two ideas, one was to
put each users files into a subdirectory named after their user name, and
two the one that im using, was to first upload the file to the server, add a
database entry and return the result of the @.@.IDENTITY to my program then
preclude the name of the file with the identity value.

thus... myresume.doc would become 243_myresume.doc

Hope those help,
Muhd

"Tom" <tomgaomail@.optushome.com.au> wrote in message
news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
>I considered that option.. however storing path is not the ideal option as
> many users may have the same image or icon thus resulting the same image
> being sent to all users when the image are suppose to be different as the
> image gets overridden when they're the same file name
> any other ideas ?
> thanks
> Tom
> "Simon Hayes" <sql@.hayes.ch> wrote in message
> news:415175e2$1_2@.news.bluewin.ch...
>>
>> "Tom" <tomgaomail@.optushome.com.au> wrote in message
>> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
>> > hello friends
>>> > I want to specify a field to save icons I want to give this field a
>> > maximum
>> > of 120kb for each icon to be stored in the db.
>>> > what datatype should I assign to this field and how do I specify the
> size
>> > ?
>>> > Thanks
>> > Tom
>>>>
>> The image data type is the one used for large binary data, but you can't
>> specify a size - 2GB is the maximum allowed. Another common approach is
>> to
>> leave the binary files in the filesystem, and simply store the path to
>> the
>> file in a varchar column.
>>
>> Simon
>>
>>|||thanks thats a great idea

but I'm also curious would it be possible to store the icons into a binary
field and set the size of that binary field ?

Thanks
Tom

"Muhd" <eat@.joes.com> wrote in message
news:cRj4d.493991$gE.369174@.pd7tw3no...
> I had a similar problem where i wanted people to store files on my web
> server, because i was worried about file name clashes i was considering
> storing them in the database. Instead I came up with two ideas, one was
to
> put each users files into a subdirectory named after their user name, and
> two the one that im using, was to first upload the file to the server, add
a
> database entry and return the result of the @.@.IDENTITY to my program then
> preclude the name of the file with the identity value.
> thus... myresume.doc would become 243_myresume.doc
> Hope those help,
> Muhd
>
> "Tom" <tomgaomail@.optushome.com.au> wrote in message
> news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
> >I considered that option.. however storing path is not the ideal option
as
> > many users may have the same image or icon thus resulting the same image
> > being sent to all users when the image are suppose to be different as
the
> > image gets overridden when they're the same file name
> > any other ideas ?
> > thanks
> > Tom
> > "Simon Hayes" <sql@.hayes.ch> wrote in message
> > news:415175e2$1_2@.news.bluewin.ch...
> >>
> >> "Tom" <tomgaomail@.optushome.com.au> wrote in message
> >> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
> >> > hello friends
> >> >> > I want to specify a field to save icons I want to give this field a
> >> > maximum
> >> > of 120kb for each icon to be stored in the db.
> >> >> > what datatype should I assign to this field and how do I specify the
> > size
> >> > ?
> >> >> > Thanks
> >> > Tom
> >> >> >>
> >> The image data type is the one used for large binary data, but you
can't
> >> specify a size - 2GB is the maximum allowed. Another common approach is
> >> to
> >> leave the binary files in the filesystem, and simply store the path to
> >> the
> >> file in a varchar column.
> >>
> >> Simon
> >>
> >>|||Tom wrote:
> thanks thats a great idea
> but I'm also curious would it be possible to store the icons into a binary
> field and set the size of that binary field ?
> Thanks
> Tom

NO, you can't specify the size of an image columt - it's variable up to 2 GB.
Here are all the types MS SQL has:

http://www.databasejournal.com/feat...le.phpr/2212141

WYGL,
Andrey|||
As has already been stated, you can't 'set' the size of field, but since your code would load an image
into the field, it could check that the size is within limits before loading it.

--
__________________________________________________ _____
http://www.ammara.com/
Image Handling Components, Samples, Solutions and Info
DBPix 2.0 - lossless jpeg rotation, EXIF, asynchronous

"Tom" <tomgaomail@.optushome.com.au> wrote:
>thanks thats a great idea
>but I'm also curious would it be possible to store the icons into a binary
>field and set the size of that binary field ?
>Thanks
>Tom
>"Muhd" <eat@.joes.com> wrote in message
>news:cRj4d.493991$gE.369174@.pd7tw3no...
>> I had a similar problem where i wanted people to store files on my web
>> server, because i was worried about file name clashes i was considering
>> storing them in the database. Instead I came up with two ideas, one was
>to
>> put each users files into a subdirectory named after their user name, and
>> two the one that im using, was to first upload the file to the server, add
>a
>> database entry and return the result of the @.@.IDENTITY to my program then
>> preclude the name of the file with the identity value.
>>
>> thus... myresume.doc would become 243_myresume.doc
>>
>> Hope those help,
>> Muhd
>>
>>
>> "Tom" <tomgaomail@.optushome.com.au> wrote in message
>> news:41519884$0$20125$afc38c87@.news.optusnet.com.a u...
>> >I considered that option.. however storing path is not the ideal option
>as
>> > many users may have the same image or icon thus resulting the same image
>> > being sent to all users when the image are suppose to be different as
>the
>> > image gets overridden when they're the same file name
>>> > any other ideas ?
>> > thanks
>> > Tom
>>> > "Simon Hayes" <sql@.hayes.ch> wrote in message
>> > news:415175e2$1_2@.news.bluewin.ch...
>> >>
>> >> "Tom" <tomgaomail@.optushome.com.au> wrote in message
>> >> news:41512fbd$0$23894$afc38c87@.news.optusnet.com.a u...
>> >> > hello friends
>> >>> >> > I want to specify a field to save icons I want to give this field a
>> >> > maximum
>> >> > of 120kb for each icon to be stored in the db.
>> >>> >> > what datatype should I assign to this field and how do I specify the
>> > size
>> >> > ?
>> >>> >> > Thanks
>> >> > Tom
>> >>> >>> >>
>> >> The image data type is the one used for large binary data, but you
>can't
>> >> specify a size - 2GB is the maximum allowed. Another common approach is
>> >> to
>> >> leave the binary files in the filesystem, and simply store the path to
>> >> the
>> >> file in a varchar column.
>> >>
>> >> Simon
>> >>
>> >>
>>>>
>>

Image not displayed in report

Hello everyone,

I have a Reporting Services report which must show photographs stored in a SQL Server database. The trouble is that the photos just don't display. The report just shows the little red cross icon.

When I use MS-Access forms and reports it works fine. But I need this to work with Reporting Services!

Help please!

Jerome

What data type are the pictures stored in SQL DB? You may want to change the MIMEType of the Image control on your report to see if which one is correct. I've been using image/bmp to accommodate pictures stored as varbinary data type. HTH.|||

Hi.

I discovered that the problem has to do with the way Access stores images. It stores all the OLE data necessary to display the images in Access, but this is not compatible with SQL Server. I solved the problem by purchasing and installing DBPix software. It cost me US$ 100.

Cheers,

Jerome

|||

Technet has an article about how to access OLE images. See the section entitled 'Task List Item 2 – Database Images' in http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/migratereports.mspx. Note that the code as presented only works for OLE images created on an en-US system:

Code Snippet

=System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields.Picture.Value),105))

For images created on other locales, check out this post: http://forums.devarticles.com/showpost.php?p=51707&postcount=3.

Thanks.

Image not displayed in report

Hello everyone,

I have a Reporting Services report which must show photographs stored in a SQL Server database. The trouble is that the photos just don't display. The report just shows the little red cross icon.

When I use MS-Access forms and reports it works fine. But I need this to work with Reporting Services!

Help please!

Jerome

What data type are the pictures stored in SQL DB? You may want to change the MIMEType of the Image control on your report to see if which one is correct. I've been using image/bmp to accommodate pictures stored as varbinary data type. HTH.|||

Hi.

I discovered that the problem has to do with the way Access stores images. It stores all the OLE data necessary to display the images in Access, but this is not compatible with SQL Server. I solved the problem by purchasing and installing DBPix software. It cost me US$ 100.

Cheers,

Jerome

|||

Technet has an article about how to access OLE images. See the section entitled 'Task List Item 2 – Database Images' in http://www.microsoft.com/technet/prodtechnol/sql/2000/deploy/migratereports.mspx. Note that the code as presented only works for OLE images created on an en-US system:

Code Snippet

=System.Convert.FromBase64String(Mid(System.Convert.ToBase64String(Fields.Picture.Value),105))

For images created on other locales, check out this post: http://forums.devarticles.com/showpost.php?p=51707&postcount=3.

Thanks.

image located on web, url for image stored in database

Hi,

I have a website and i am uploading the gif image to the database. i have used varchar(500) as the datatype and i am saving the file in the webserver so the path to it c:\intepub\....a.gif

my upload table has the folliwing feilds

UploadId Int Identity, Description, FileName, DiskPath varchar(500), weblocation varchar(500). I have a main sproc for the report where i am doing a inner join with other table to get the path of the gif..

So my question is how can i get a picture to show up on the report. .

What kinda datatype the gif file should be stored in the database? If it is stored as a varchar how can i access it and what is best way to reference that particular.

any help will appreciated....

Regards

Karen

This should help:

http://technet.microsoft.com/en-us/library/ms156482.aspx

But I must ask, why do you want to store the image in your database? Why not just host it on a website?

|||Anyone know a way to do this? I want to create a report that will use a table from sql that has a url which points to an image. I want this image to show up in a table in my report. The end goal is to have a searchable report with parameters that supplies immages (from the web) based on search criteria.
|||

Greg,

I have stored the image as a gif file on my webserver, but i couldnt access it, but now i gave the url to it and then specified it as a external image and everything works fine.. i am storing the reference to the image.... in the database.

Thanks a lot.

Regards

Karen

|||If I understand this post, I am having simmilar difficulties. I want to have a table in sql that has verious links to images locaed on the web. I want to display these images in my report. I'm quite confused and pretty new to this so if you can treat me like I know nothing at all and show me step by step what you did I'd really appreciat it.
|||

I have merged the two threads as they are highly related.

|||

Mflancour,

I am uploading the image using a file upload control in the database. and i am storing the like a URL http://Ipaddress/Nameoftheapplication/anyfolders/andsubfoldersintheapplication/Filename.gif. This field is set up in a my database as varchar(500) so i will be storing the above information in that field.

Then, in reporting service .... get the field that u want to access in the particular dataset

From the tool box select image and follow the wizard and select Database and then select the dataset and the field

then select the image and in the properties change the source to external and preview it.

and it should work

hope this helps.

Karen

|||Nevermind figured it out based on your earlier posts
sql

Image Insertion

Dear All,
I want to know how to insert image in sqlserver.
If it can be stored by any frontend like vb, pl. do tell me how?
-MaitreyaLook at the methods GetChunk and AppendChuck, which are 2 methods used with ADO.

Here is a link the Microsoft article

HOWTO: Read and Write BLOBs Using GetChunk and AppendChunk (Q194975)
(http://support.microsoft.com/default.aspx?scid=kb;EN-US;q194975)

Wednesday, March 21, 2012

Image data type

I have been asked to write a piece of code that will insert an image object into a database using a stored procedure and the Microsoft Enterprise Library. Has anyone done this before? Do you have any code examples about how to update a database with an image datatype that needs to be chunked, etc...

In this instance, I need to open up a word document and save the contents as an image in a database.

basically you want to get the uploaded file into a byte array and then you can assign it to a sql param of type image, no chunking needed

here's a snip from one of my projects. I'm using business objects so its not showing the actual sql code but behind the scenes it is just assigning it to a param of type image

byte[] fileBytes = new byte[replacementFileInput.ContentLength];
Stream contentStream = replacementFileInput.FileContent;

contentStream.Read(fileBytes, 0, (int) replacementFileInput.ContentLength);
contentStream.Close();

DocumentFile newFile = new DocumentFile(true);
newFile.DocumentID = originalDocument.ID;
newFile.DocumentType = documentType.Name;
newFile.DocumentImage = fileBytes;
newFile.Save();

I should note that in my example I'm usingNeatUpload, so replacementFileInput is the NeatUpload file input and has a little different syntax then the regular .NET file input

NeatUpload can handle large file uploads gracefully with a progress bar and is free and open source

Hope it helps,

Joe|||

I downloaded the NeatUpload. This does look pretty cool. However, in the instance I'm currently in, I have a Word Document already on the server that I need to convert to a binary object and upload to SQL. The answer is probably right in front of me, so... following your initial tip.

How do I convert an existingWord Document into a byte array?

|||Yes, you can easily do this. In my previous example I was using the contentStream from the uploaded file, but any subclass of stream could be used, so in your case FileStream which you can get with something like this:

FileStream fileStream = File.Open("pathtoyourfile", FileMode.Open);
byte[] fileBytes = new byte[fileStream.Length];
fileStream.Read(fileBytes, 0, (int)fileStream.Length);

now fileBytes has the file and you can assign it to your sql image param

Hope it helps,

Joe|||

This is great, thanks! I think I got the record in there... Now I just have to read it! Big Smile

Thanks for your help, Joe.

-Scott

|||

Okay, I have been struggling to convert the following code from C# to VB. Particularly at the point of creating the New Byte. Can anyone help?

SqlCommand cmdSelect=new SqlCommand("select Picture" +
" from tblImgData whereID=@.ID",this.sqlConnection1);
cmdSelect.Parameters.Add("@.ID",SqlDbType.Int,4);
cmdSelect.Parameters["@.ID"].Value=this.editID.Text;

this.sqlConnection1.Open();
byte[] barrImg=(byte[])cmdSelect.ExecuteScalar();
string strfn=Convert.ToString(DateTime.Now.ToFileTime());
FileStream fs=new FileStream(strfn,
FileMode.CreateNew, FileAccess.Write);
fs.Write(barrImg,0,barrImg.Length);
fs.Flush();
fs.Close();
pictureBox1.Image=Image.FromFile(strfn);

Image Data Type

I have a column that has audit details stored as an image data type. How do i convert that into meaningful data that i can read.
Example:
0x78F992BD69BF23BE243134839506265892223083981A6104 A389A1B1918129B6303035B434C7748FAF63508887A33B99CB AE4C8C4C8D71B68DCC8CCC8C0D4D71350040B246C603309AEE 1810E0EAE8437046C3C440D7C48892414E007B1F8BED
I am guessing this is text with fomatting instructions. Because in the software that utilized this database, this field seems to be interpreted as a hierarachial table showing the audit details of an event.

please offer any suggestions you can.
thanks so muchActually this is binary data. The only way to access or read it is through an application. See www.asp.net for some examples of how to access the data.|||Is this a BLOB file that i can use a filestream object to import into a VB application? Sorry for my newbieness.

thanks

Mardi|||Yes, an IMAGE is a blob. Typically, it is at least an 8 kb blob in order to use the database space effectively, although it can be smaller.

-PatP

image data type

I have documents stored in an image field. How can I mass
convert them to inividual disk files?You might want to try the TEXTCOPY.EXE utility that comes with SQL Server.
It is found in the \Binn folder with your SQL Server Installation location.
The utility copies a single text or image value into or out of SQL Server.
Navigate to that folder (in your DOS command prompt) and type TEXTCOPY.EXE
/? for more help.
Nathan H.O.

Image Data and PATINDEX function

Hi,
I need to retrieve the offset of some text stored as image. PATINDEX does not work for image data type. What other choice do I have?
Thank you,
Amar DasAre you searching for the text or the binary pattern of the text?

Use the image datatype for storing binary data and (n)text datatype for storing text.|||Thanks Paul.

I am searching for the text. Unfortunately the table is created by my client and I can not alter it.|||Hum... Books Online seems to have some errors...

try this...
create table #Tmp(f1 text, f2 image)
insert into #Tmp values('Test number 1','Test number 1')
insert into #Tmp values('Test number 2','Test number 2')
insert into #Tmp values('Test number 3','Test number 3')
insert into #Tmp values('Test number 4','Test number 4')
select charindex(cast('r 2' as varbinary),f2),* from #Tmpsql