473,671 Members | 2,257 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding images to the database

Looking for an idea here. I've got a .Net app connecting to SQL2005 where I
allow users to add pictures to the database. But I don't want them adding
gigantic images, so I'm looking for an idea on how to control how big of an
image they might add. I'm not interested in simply saving a pointer to a
file here.
Nov 30 '06 #1
3 1893
varbinary (max) would automatically limit them to 2 GB size, but your best
bet might be to check the size on the client side if you want to limit them
to say 10 MB or something. If you send it to the server first, someone
might have just spent all that time uploading a 100 MB file only to have it
error on them. That's a waste of time and bandwidth. If you want to ensure
that, for instance, your developers can't work their way around the system
and bypass the client app to insert larger files you might look into
triggers as well.

"Earl" <br******@newsg roups.nospamwro te in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Looking for an idea here. I've got a .Net app connecting to SQL2005 where
I allow users to add pictures to the database. But I don't want them
adding gigantic images, so I'm looking for an idea on how to control how
big of an image they might add. I'm not interested in simply saving a
pointer to a file here.

Dec 1 '06 #2
Earl,

the most easiest way is in my idea to use the thumbnail.

In this sample is that used.
Dim fo As New OpenFileDialog
If fo.ShowDialog = DialogResult.OK Then
PictureBox1.Ima ge = PictureBox1.Ima ge.FromFile(fo. FileName)
Dim Thumbnail As System.drawing. Image = _
PictureBox1.Ima ge.GetThumbnail Image(32, 32, Nothing, New IntPtr)
PictureBox2.Ima ge = Thumbnail
End If
I hope this helps,

Cor
"Earl" <br******@newsg roups.nospamsch reef in bericht
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
Looking for an idea here. I've got a .Net app connecting to SQL2005 where
I allow users to add pictures to the database. But I don't want them
adding gigantic images, so I'm looking for an idea on how to control how
big of an image they might add. I'm not interested in simply saving a
pointer to a file here.

Dec 1 '06 #3
Thanks to all, Mike, Mikael and Cor. Looks like I'm going to resize on the
client side using the new Width and Height. I can certainly see uses for
thumbnails though.

"Mikael Gustavsson" <Mi************ **@discussions. microsoft.comwr ote in
message news:24******** *************** ***********@mic rosoft.com...
Hi!

If you wish for the image to be anything else than a thumbnail I would
suggest that you resize the image instead of using the GetThumbnailIma ge.
Resizing the image is pretty simple Here is an example.

Bitmap bmp = new Bitmap(uploaded Image, newWidth, newHeight);
bmp.Save(myStre am, System.Drawing. Imaging.ImageFo rmat.Png)

You can also use encoding parameters to save the image in order to change
compression and such. Then just remember that you can user
System.Drawing. Imaging.ImageFo rmat.<imagetype >.Guid to get the correct
guid
for the encoder.

Good luck!

//Micke

"Cor Ligthert [MVP]" wrote:
>Earl,

the most easiest way is in my idea to use the thumbnail.

In this sample is that used.
Dim fo As New OpenFileDialog
If fo.ShowDialog = DialogResult.OK Then
PictureBox1.Ima ge = PictureBox1.Ima ge.FromFile(fo. FileName)
Dim Thumbnail As System.drawing. Image = _
PictureBox1.Ima ge.GetThumbnail Image(32, 32, Nothing, New IntPtr)
PictureBox2.Ima ge = Thumbnail
End If
I hope this helps,

Cor
"Earl" <br******@newsg roups.nospamsch reef in bericht
news:%2******* *********@TK2MS FTNGP03.phx.gbl ...
Looking for an idea here. I've got a .Net app connecting to SQL2005
where
I allow users to add pictures to the database. But I don't want them
adding gigantic images, so I'm looking for an idea on how to control
how
big of an image they might add. I'm not interested in simply saving a
pointer to a file here.



Dec 1 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2437
by: mark | r | last post by:
ok, so i now know how to add, edit, delete and search for products (havent figured out categorisation out yet tho) - how do i upload an image and save the file name to the database as part of the admin? something dummies can follow that doesnt use a component (can i throw in a chunk of code and specify the table fieldname and directory the file needs to go into?) cheerz mark
3
1801
by: Chris Minchin | last post by:
Hi there, I am a bit of a newboy to access I have a database which I wish to have pictures. for example: record one will have data and a picture, record two will have different data and a diferent picture. I am pretty sure that a picture bound frame is used, but are unable to make it work. Anybody able to help? Chris
10
2322
by: Neo Geshel | last post by:
I am seeking to hand-roll my own blog in ASP.NET 2.0 and SQLExpress 2005. Why? Because I can. Because I will gain experience. The one thing that has me stumped at square one is inline images. That is, images inline with the actual content of the blog itself. Is there an example that I can be pointed to, where I can examine some code and figure out how to do this? Frankly I haven't got a clue, aside from breaking the content up into...
9
2772
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
3
1457
by: Earl | last post by:
Looking for an idea here. I've got a .Net app connecting to SQL2005 where I allow users to add pictures to the database. But I don't want them adding gigantic images, so I'm looking for an idea on how to control how big of an image they might add. I'm not interested in simply saving a pointer to a file here.
10
13402
by: eholz1 | last post by:
Hello Members, I am setting up a photo website. I have decided to use PHP and MySQL. I can load jpeg files into the table (medium blob, or even longtext) and get the image(s) to display without a problem. I am using chunk_split(data) and the base64_encode and base64_decode on the files. I do a select from the database, and then echo the image (with header(Content Type: image/jpeg) and the decoded image displays fine. Yes, I have...
1
1802
by: colmkav | last post by:
Hi, when I try to add a logo to my form I click on the unbounded object frame and then browse for tje location of my logo. I open the .bmp file but get an error claiming "OLE object isnt registered". I get same type of error for other items I try to upload. could someone pls tell me how I can resolve this problem?.
3
2470
by: najimou | last post by:
Hi everyone I will be having a split database, running on 2 computers via mapped drive. computer "A" will have one front end and the back end located in c: \mydatabse 2 tables have links to many images stored as c:\mydatabse\images \images.jpg so computer A has no problem accessing the picture
1
4895
by: swethak | last post by:
Hi, I am desiging the calendar application for that purpose i used the below code. But it is for only displys calendar. And also i want to add the events to calendar. In that code displys the events when click on that date that perticular event displyed in a text box.But my requirement is to when click on that date that related event displyed in same td row not the text box. and also i add the events to that calendar.plz advice how to...
0
8476
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8917
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8598
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8670
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7437
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6229
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4407
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.