Personal Technology Information |
|
How to Save an Image in a SQL Server Database?
Most of the web applications have a lot of images used in it. These images are usually stored in a web server folder and they are accessed by giving the relative path to the file with respect to the root folder of the website. .Net being the platform for distributed application now, ASP.Net can be used to store images that are small to be stored in a database like SQL Server 2000 and later versions. For this purpose the SQL Server database provides a data type called "image" which is used to store images in the database. To access these images stored in the database we will be using the ADO.Net classes. To find out how to insert and retrieve an image in to the SQL Server database, you can create a .aspx page which can have a HTMLInputFile control which is used to select the image file that is to be saved in the database. You can also create a textbox control in which you can add the image name or some comment or an image id for the image saved. Use a button control to upload the image to the database. Namespaces like System.Data.SqlClient, System.Drawing, System.Data, System.IO, and System.Drawing.Imaging are used in this task. In the OnClick property of the button you can write the following code to upload an image to the database. // create a byte[] for the image file that is uploaded You can also write the above code in a function and call that function in the OnClick event of the upload button. The code given above performs the following steps in the process of inserting an image into the database. 1. Get the content length of the image that is to be uploaded To retrieve the image from the SQL Database you can perform the following steps. 1. Create a MemoryStream object. The code can be something like, MemoryStream mstream = new MemoryStream (); 2. Create a Connection object 3. Open the connection to the database 4. Create a command object to execute the command to retrieve the image 5. Use the command object's ExecuteScalar method to retrieve the image 6. Cast the output of the ExecuteScalar method to that of byte[] byte[] image = (byte[]) command.ExecuteScalar (); 7. Write the stream mstream.Write (image, 0, image.Length); 8. Create a bitmap object to hold the stream Bitmap bitmap = new Bitmap (stream); 9. Set the content type to "image/gif" Response.ContentType = "image/gif"; 10. Use the Save method of the bitmap object to output the image to the OutputStream. bitmap.Save (Response.OutputStream, ImageFormat.Gif); 11. Close the connection 12. Close the stream mstream.Close(); Using the above steps you can retrieve and display the image from the database to the web page. You can use these algorithms and take advantage of the "image" data type available in the SQLServer 2000 database to store small images that correspond to a particular record in the table of the database. This method of storing avoids the tedious task of tracking the path of the web folder if the images are stored in a web folder. Visit A Guide to .NET for a complete introduction to .NET framework. Learn about ASP.NET, VB.NET, C# and other related technologies.
MORE RESOURCES: What I Got Wrong in a Decade of Predicting the Future of Tech The Wall Street Journal ‘Data is the new oil’: Virginia Tech professor wants to protect the personal data of marginalized communities WRIC ABC 8News Smartphones Can Now Last 7 Years. Here's How to Keep Them Working. The New York Times iPad Pro vs. MacBook: The Great Apple Laptop Trade-Off The Wall Street Journal Opinion | Technology Hates Me The New York Times In the City, Personal Safety Starts With Your Smartphone The Wall Street Journal Jonathan Haidt’s ‘The Anxious Generation’: Tech, Smartphones Cause Teen Anxiety The Wall Street Journal Tech That Will Change Your Life in 2024, From AI to EV - WSJ The Wall Street Journal Want to Get More Done? That Podcast in the Background Is Holding You Back The Wall Street Journal Apple's New iPad Pro vs. New iPad Air vs. iPad: Why Are There So Many? The Wall Street Journal How TikTok Is Wiring Gen Z's Money Brain The Wall Street Journal OpenAI Made AI Videos for Us. These Clips Are Good Enough to Freak Us Out. - WSJ The Wall Street Journal The Invisible $1.52 Trillion Problem: Clunky Old Software The Wall Street Journal After a Sugar High of Free Money, These Billion-Dollar Technologies Need a Nap The Wall Street Journal Huawei's latest smartphone mostly made in China The Register We Aren't Posting on Social Media as Much Anymore. Will We Ever? The Wall Street Journal The Tech to Help You Beat Your Tech Addictions The Wall Street Journal Tech Hubs Are Losing the Talent War to Everywhere Else The Wall Street Journal What Kind of Driver Will Your Kid Be? This Test Can Tell. The Wall Street Journal iPhone Fixes to Make if You're the Family IT Department This Year The Wall Street Journal AT&T, Verizon, Sprint, T-Mobile US fined $200M for selling off people's location info - The Register I Bought the World's Hottest High-Tech E-Bike. Then Its Maker Went Bankrupt. The Wall Street Journal Hands Off! With $3500 Headsets in the Wild, New Social Norms Apply The Wall Street Journal Apple's New Face Computer Is for Work The Wall Street Journal Schools Want to Ban Phones. Parents Say No. The Wall Street Journal Niklaus Wirth, Who Inspired a Generation of Computer Programmers, Dies at 89 The Wall Street Journal Vision Pro Review: Apple's First Headset Lacks Polish and Purpose The New York Times He Stole Hundreds of iPhones and Looted People's Life Savings. He Told Us How. The Wall Street Journal The Accounting Technology Lab Podcast: Personal Tech at CES 2024 CPAPracticeAdvisor.com Boys Are Struggling. It Can Take Coaches, Tutors and Thousands a Month to Fix That. The Wall Street Journal 12 Apps We Can't Stop Using, for Better or Worse The Wall Street Journal 100 Cool Tech Gadgets in 2024, According to a Tech Expert BestProducts.com Best Tech Gifts of 2023 to Buy This Holiday Season, an Updated List - WSJ The Wall Street Journal Yun-Hee Kim promoted to Tech Editor, Corporate and Personal Technology The Washington Post The Four Steps to Better Password Security The Wall Street Journal Testing Apple’s Vision Pro The New York Times Turn On Your iPhone's Stolen Device Protection Now to Secure Your Money and Photos in iOS 17.3 Update - WSJ The Wall Street Journal Meta’s Ray-Ban Smart Glasses Use AI to See, Hear and Speak. What Are They Like? The New York Times Snapchat's Friend-Ranking Feature Adds to Teen Anxiety The Wall Street Journal A Pain-Free Way to Secure All Your Online Accounts The Wall Street Journal Is the $139 Amazon Prime Subscription Still Worth It? The Wall Street Journal The Apple Video Feature Awkwardly Crashing Your Meetings - WSJ The Wall Street Journal What if You Never Had to Charge Your Gadgets Again? The Wall Street Journal The most personal technology | Jul 22nd 2023 The Economist Quick Tips to Save Time on the Telephone The New York Times Apple’s iOS 17.3 Stolen Device Protection Update Aims to Stop iPhone Thieves The Wall Street Journal Don't rent out that container ship yet: CIOs and biz buyers view AI PCs with some caution The Register Do You Have Painful 'Tech Neck?' This Expert-Approved Gadget Might Help The Wall Street Journal The Most Important Tech Company You've Never Heard of Is a Major Reason Computers Keep Getting Faster The Wall Street Journal Faster, Beefier, Cheaper: The Next-Generation Electric Skateboards Have Arrived The Wall Street Journal Sluggish Wi-Fi? Weird Party Smells? 8 High-Tech Helpers for Harried Holiday Hosts The Wall Street Journal Meta Welcomes Headset War With Apple - WSJ The Wall Street Journal Meta and Google Are Betting on AI Voice Assistants. Will They Take Off? The New York Times Distracted, Forgetful and Hooked on Smartphones: Why More Women Are Being Diagnosed With ADHD The Wall Street Journal Yes, It's Rude to Use Your Laptop During Meetings—and More Tech Etiquette Rules You Might Be Breaking The Wall Street Journal Ten years ago Microsoft bought Nokia's phone unit – then killed it as a tax write-off The Register You're Brewing It Wrong: The Coffee-Making Myths That Might Be Holding You Back The Wall Street Journal How to Cut Down Your Screen Time but Still Get Stuff Done The New York Times Why Tech Companies Are Not Your Friends: Lessons From Roku The New York Times EU duties might not hold off flood of China EVs The Register BASICally still alive: Classic language celebrates 60 years with new code and old quirks The Register New Tech That Asks 'Are You Sure About Sending a Nude Photo?' The Wall Street Journal How to Make Your Phone Last Forever: 6 Simple Tips The Wall Street Journal |
RELATED ARTICLES
More Cool Web Tricks If you ask most people what frustrates them most about the Internet, many of them will tell you "It's the little things!"It seems like all the great tricks and tips that make people exclaim "STOP! How did you do that?" never make it into any manual (at least where I can find them).My father (and co-author of "Turn Words Into Traffic") calls it the "reverse oral tradition" of computing, where children teach parents the survival skills of PC life. A Peek Into the Near Future of Electronics Technology How long do you think DVDs have around? 20 years? 10 years? Actually, they have only been around for about seven years, but it seems like they have been around much longer. Many of us can hardly remember life before DVDs. Cisco Certification: A Survival Guide To The Cisco Cable Jungle One of the most confusing parts of beginning your Cisco studies is keeping all the cable types separate in your mind, and then remembering what they're used for. This often occurs when a CCNA or CCNP candidate starts putting together their own home practice lab, and they suddenly realize that they have the equipment to run labs, but not the cables. CCNA 640-801 Certification Primer The Cisco Certified Network Associate (CCNA) Certification is meant for career enhancement as well as gaining knowledge of the LAN/WAN technologies currently available for implementation. Hence, CCNA Certification can be obtained by IT professionals who have been a part of the industry for a considerable time and are interested in furthering their career in terms of role enhancement and salary. Tips for Buying a PC Buying Your PCBuying a PC that's right for you and your family is not all that simple task. More so if you're going to buy an unbranded or an assembled one. What's the Difference Between Plasma TVs and LCD TVs? Plasma and LCD TVs are the latest trend in home entertainment. Both offer unrivalled picture quality and resolution, while doing away with the bulkiness of the older rear-projection technologies. Is Your Web Browser Putting You At Risk? It's free, it comes with Windows and it's used by approximately 94% of the Internet population. It also poses an unacceptable security risk. Is Online DVD Rental or Pay-Per-View the Best Way to Get Your Movies? With renting methods such as online DVD rental and pay-per-view, it seems almost old-fashioned to go to the rental store. But with all the different ways to get the latest movies, which way is the best? Well, that depends on what is important to you. Flash Your nVidia Video Cards BIOS You will need the following:1. 1. Tips For Getting Technical Support Help Online Sometimes your PC will start acting strange for no apparent reason or a program which you use regularly will all of a sudden stop working as it should. This can be a frustrating experience especially if you have no idea where to go for help. Cisco CCNA Candidate FAQ CCNA FAQQ. What exams do I have to take to get my CCNA?A. Help, I Need a New HDTV! (Part 5 of 5) Feeling overwhelmed in selecting a new TV? With all the choices these days, you may feel like, "Where do I start?!"In the final part of our 5 part article, we the discuss tv recommendations by room.--Bedrooms and kids rooms. Cisco Certification: Building Your Own Home Lab, Part I CCNAs and CCNA candidates hear it all the time: â??Get some hands-on experienceâ??. From my personal experience climbing the Cisco certification ladder, I can tell you firsthand that there is no learning like hands-on learning. 10 Easy Steps to Speed Up Your Computer - Without Upgrading 1. Empty the Temp directory regularly. 5 Simple Ways To Increase Your Computer Speed & Help Your Computer Run More Efficiently! If you're a computer expert, you'll probably already know about these tips (hopefully this will provide you with a little reminder). If you're not an expert, don't worry - these tips are simple, and don't require a lot of computer experience. D2X Digital SLRCoolpix 8800 Actually Refers to Two Nikon Cameras Addressing a D2X Digital SLRCoolpix 8800 search, this article provides a quick comparison of the Nikon D2X digital SLR and Coolpix 8800 cameras.Nikon D2X Professional Digital SLRCheck out a Nikon D2X review or two and quickly realize this is a world class professional digital SLR. The Benefits of the New Firefox Browser You probably heard of the new Firefox browser version 1.0 recently released by Mozilla. Cisco Certification: What To Expect On Exam Day Cisco Certification: Taking Your First Certification ExamYou've studied hard; you've practiced your configurations; you've used your flash cards over and over again; and finally, the big day is here. Your first certification exam!For many Cisco certification candidates, their first exam is the CCNA Composite exam or one of the two exams that make up the CCNA, the Introduction To Networking exam or the ICND (Interconnecting Cisco Networking Devices) exam. Are You Well Protected? Winter?the official start of the cold and flu season. Though, technically speaking, things got started a little early. Virtual Memory - What is It? I recently got an e-mail asking about virtual memory. The person who sent me the question was getting an error on random occasions from their Windows operating system stating "Your computer is low on virtual memory". |
home | site map |
© 2006 |