Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

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 problem

Hello,

I'm using SQL 2005 & reporting service 2005

I have a picture control and the image come from a web. (http://myserver/logo.jpg)

The report contain parameters.

While user generate the reporting the image display without a problem.

But if user change his parameters selected (without close the reports) than click on generate report the image doesn't dispaly and red X show.

If user click on the refresh icon in the report the image load again.

Any sugestion how to solve this problem ?

Thanks

I had a similar problem before and had to use an embedded image instead to get rid of the problem.|||This issue was addressed in SP1. After applying SP1, are you still seeing the issue?|||I still didn;t applay SP1 because the "Select All" in ,ulti selection list removed in SP1|||If you don't want to apply SP1, then the only workaround is to use an embedded image instead.|||Thanks

Image not displayed in report

I am creating a very simple report in VS 2005. I dragged an image
control to the report surface and set it's value property to the
virtual path of my image (like "~/SubPage/Trademark.jpg"). However,
the image is never displayed - either at design time, when the report
viewer runs, or when the report is exported to PDF. I just get the
standard "No image" (red X) icon.
I have read other posts about this but most of them were trying to do
something more complicated than me. At this point, I am not trying to
do any logic for the visibility or the value it is trying to display.
I read about a bug that might be related here:
http://support.microsoft.com/kb/842537/
...but I am not sure if this pertains to me (as I am not pointing to a
URL, but rather a virtual path). I am leery of applying this SP2
patch, as there is no way to uninstall it, and I am not sure if it
will "break" anything that is currently working.
I would appreciate any suggestions that anyone could give me.
Thank you!Kirk,
Try embedding the image into the report instead of using the URL.
MM
"Kirk" wrote:
> I am creating a very simple report in VS 2005. I dragged an image
> control to the report surface and set it's value property to the
> virtual path of my image (like "~/SubPage/Trademark.jpg"). However,
> the image is never displayed - either at design time, when the report
> viewer runs, or when the report is exported to PDF. I just get the
> standard "No image" (red X) icon.
> I have read other posts about this but most of them were trying to do
> something more complicated than me. At this point, I am not trying to
> do any logic for the visibility or the value it is trying to display.
> I read about a bug that might be related here:
> http://support.microsoft.com/kb/842537/
> ...but I am not sure if this pertains to me (as I am not pointing to a
> URL, but rather a virtual path). I am leery of applying this SP2
> patch, as there is no way to uninstall it, and I am not sure if it
> will "break" anything that is currently working.
> I would appreciate any suggestions that anyone could give me.
> Thank you!
>|||I´ve also tested what you say and it does not work with relative path.
To make it work, do what Marie says or use absolute URL
(http://www.yourpage.com/Subpage/Trademark.jpg)
"Kirk" <loki70@.hotmail.com> escribió en el mensaje
news:1193753651.198915.166370@.k79g2000hse.googlegroups.com...
>I am creating a very simple report in VS 2005. I dragged an image
> control to the report surface and set it's value property to the
> virtual path of my image (like "~/SubPage/Trademark.jpg"). However,
> the image is never displayed - either at design time, when the report
> viewer runs, or when the report is exported to PDF. I just get the
> standard "No image" (red X) icon.
> I have read other posts about this but most of them were trying to do
> something more complicated than me. At this point, I am not trying to
> do any logic for the visibility or the value it is trying to display.
> I read about a bug that might be related here:
> http://support.microsoft.com/kb/842537/
> ...but I am not sure if this pertains to me (as I am not pointing to a
> URL, but rather a virtual path). I am leery of applying this SP2
> patch, as there is no way to uninstall it, and I am not sure if it
> will "break" anything that is currently working.
> I would appreciate any suggestions that anyone could give me.
> Thank you!
>|||On Oct 31, 12:21 pm, "M=F3nica" <monica.d...@.augure.com> wrote:
> I=B4ve also tested what you say and it does not work with relative path.
> To make it work, do what Marie says or use absolute URL
> (http://www.yourpage.com/Subpage/Trademark.jpg)
> "Kirk" <lok...@.hotmail.com> escribi=F3 en el mensajenews:1193753651.19891=5=2E166370@.k79g2000hse.googlegroups.com...
>
> >I am creating a very simple report in VS 2005. I dragged an image
> > control to the report surface and set it's value property to the
> > virtual path of my image (like "~/SubPage/Trademark.jpg"). However,
> > the image is never displayed - either at design time, when the report
> > viewer runs, or when the report is exported to PDF. I just get the
> > standard "No image" (red X) icon.
> > I have read other posts about this but most of them were trying to do
> > something more complicated than me. At this point, I am not trying to
> > do any logic for the visibility or the value it is trying to display.
> > I read about a bug that might be related here:
> >http://support.microsoft.com/kb/842537/
> > ...but I am not sure if this pertains to me (as I am not pointing to a
> > URL, but rather a virtual path). I am leery of applying this SP2
> > patch, as there is no way to uninstall it, and I am not sure if it
> > will "break" anything that is currently working.
> > I would appreciate any suggestions that anyone could give me.
> > Thank you!- Hide quoted text -
> - Show quoted text -
Thanks for the replies. I used the absolute URL and that worked.
It's unfortunate that this does not work with a relative path.
Obviously, thing change (and move around on servers) and having to
update the application just to update absolute URL's is goofy. I
know, I know, you can add this as a configuration setting so that you
don't have to rebuild the site - I was just whining.
Thanks again!

Wednesday, March 21, 2012

Image file save to DB

How to save image file to database?
Which control use best?
hy..
seaching on google might be beneficial :)
Also.. U can check these articles -->
Creating and Saving Images to DataBase
Saving Images in SQL (1)
Saving Images in SQL (2)

Yes [Y]

Image control in RDLC report page.

Using RDLC report file, How can i set the image path on image control to the image in my folder \images.

I don't see any ImageURL property in such control.

thanks,

Hi,

From your description, it seems that you want to add a image in your report, right?

You can include stored images in a report by specifying a URL to the image. When you use an external image in a report, the image source is set to External and the value for the image is the URL address to the image. For a report published to a report server configured for native mode, use a full or relative path. For example,http://<servername>/images/image1.jpg. For a report published to a report server configured in SharePoint integrated mode, use a fully qualified URL. For example,http://<SharePointservername>/<site>/Documents/images/image1.jpg.

For more information, see:

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

Thanks.

Monday, March 19, 2012

image control file share

I need to add an image in a report, the images are stored on a file share, i
get the path to the image from a database.
How do I set the image control properties to read from the file share. I
tried setting the Source as External and then put the unc path in the Value
property. But that did not work.
MikeHave you considered storing the images in your database? You could use a
varbinary field. It's easier to manage pictures that way IMOHO. And it works
really well in SSRS.
Alain Quesnel
alainsansspam@.logiquel.com
www.logiquel.com
"Mike Read" <mread@.brunsco.net> wrote in message
news:OovejNEOIHA.2064@.TK2MSFTNGP06.phx.gbl...
>I need to add an image in a report, the images are stored on a file share,
>i get the path to the image from a database.
> How do I set the image control properties to read from the file share. I
> tried setting the Source as External and then put the unc path in the
> Value property. But that did not work.
> Mike
>|||This is not possible since the program that controls the images is a 3rd
party program that I have no control over.
Mike
"Alain Quesnel" <alainsansspam@.logiquel.com> wrote in message
news:%23zVGlUEOIHA.5472@.TK2MSFTNGP04.phx.gbl...
> Have you considered storing the images in your database? You could use a
> varbinary field. It's easier to manage pictures that way IMOHO. And it
> works really well in SSRS.
>
> Alain Quesnel
> alainsansspam@.logiquel.com
> www.logiquel.com
>
> "Mike Read" <mread@.brunsco.net> wrote in message
> news:OovejNEOIHA.2064@.TK2MSFTNGP06.phx.gbl...
>>I need to add an image in a report, the images are stored on a file share,
>>i get the path to the image from a database.
>> How do I set the image control properties to read from the file share. I
>> tried setting the Source as External and then put the unc path in the
>> Value property. But that did not work.
>> Mike
>|||On Dec 6, 3:04 pm, "Mike Read" <mr...@.brunsco.net> wrote:
> I need to add an image in a report, the images are stored on a file share, i
> get the path to the image from a database.
> How do I set the image control properties to read from the file share. I
> tried setting the Source as External and then put the unc path in the Value
> property. But that did not work.
> Mike
I believe that you have to use the "file:///" prefix in the URL in
order to tell the browser to pull from the local drives.
-- Scott|||Thanks, that did it.
Mike
"Orne" <polysillycon@.yahoo.com> wrote in message
news:7c55daf5-2958-4c82-a961-462e9f35746c@.i12g2000prf.googlegroups.com...
> On Dec 6, 3:04 pm, "Mike Read" <mr...@.brunsco.net> wrote:
>> I need to add an image in a report, the images are stored on a file
>> share, i
>> get the path to the image from a database.
>> How do I set the image control properties to read from the file share. I
>> tried setting the Source as External and then put the unc path in the
>> Value
>> property. But that did not work.
>> Mike
> I believe that you have to use the "file:///" prefix in the URL in
> order to tell the browser to pull from the local drives.
> -- Scott

Image control and DB

I wanna know how to retrieve & insert an image from/to a Sql Server database.

usingimage control or any other control

I've done that with windows formpicture box.

As that was explained in MS tutorials

Code….

--------------

Dim msAsNew MemoryStreamPictureBox1.Image.Save(ms, PictureBox1.Image.RawFormat)Dim arrImage()AsByte = ms.GetBuffer

ms.Close()

Dim strSQLAsString = _ "INSERT INTO Emp (EmpName,EmpSalary,Picture)" & _ "VALUES (@.EmpName,@.EmpSalary,@.Picture)" Dim cmdAsNew SqlCommand(strSQL, ConnEmp) With cmd .Parameters.Add(New SqlParameter("@.Picture", _ SqlDbType.Image)).Value = arrImage .Parameters.Add(New SqlParameter("@.EmpName", _ SqlDbType.NVarChar)).Value = txtEmpName.Text .Parameters.Add(New SqlParameter("@.EmpSalary", _ SqlDbType.Decimal)).Value = txtEmpSalary.Text EndWith

cmd.ExecuteNonQuery()

--------------

But with a web form'simage control IDO NOTknow how to do it

I real appreciate your help

Thank you

Here's an article on it:http://aspalliance.com/articleViewer.aspx?aId=140

Hope this helps...

-Damien

Wednesday, March 7, 2012

IIS & SQL Server 2005 Express Edition installation problems in Vista

Hi,

Im encountering yet another problem in Vista(Vista Home Premium). I have turned on all IIS features from control panel. When I open http://localhost it gives the error

HTTP Error 404.4 - Not Found

Description: The resource you are looking for does not have a handler associated with it

How should i resolve this?

Also, when I try to install SQL server 2005 express edition, it gives the warning that IIS is not installed, though I have installed all the features and it is running.

I have been struggling for the past one week, just to install SQL server on vista!

Please help.

Thanks

Hi,

see this here: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1270203&SiteID=1

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||

Hi, I have gone through the entire thread you pointed me to... but to no avail. I have installed asp.net under IIS without any problems, but im still having the same issues i mentioned earlier. When I open IIS manager, under handler mappings, ISAPI-dll and CGI-exe are disabled by default. Could this be a problem? How do I enable them? please help.

|||Added the defauly http handler for *.htm and *.html extensions in IIS manager. It seems fine now.