Personal Technology Information |
|
How to Use SQLXML to Retrieve Data from SQL Server Database?
Using SQL Server 2000 and above versions you can retrieve data from SQL Server in XML format directly from the database. Many XML related features were incorporated in the SQL Server database. This enables the development of XML enabled applications very easy and it makes exchange of data over internet easy. In this article we will discuss about how to use SQLXML to retrieve data directly from SQL server database in XML format. There are some SQL commands and clauses that help you to retrieve data from the SQL Server in the XML format. Syntax for such is given below: SELECT ... FOR XML mode [, XMLDATA] [, ELEMENTS] [, BINARY BASE64] There are different modes and that take the values of · AUTO - In this mode every row of the result of the query forms an element in the returned XML document. · EXPLICIT - This mode defines how to map the columns of the results returned by the query to the XML elements and the attributes. · RAW - All the fields of the result are identified as attributes of an element. · NESTED - The result of this mode is the same as the AUTO mode but the formatting has to be done at the client side. A simple example of using the above syntax is given below: SELECT TOP 3 *FROM (SELECT FirstName+' '+LastName as Name FROM Employees) FOR XML AUTO The query produces this result: Employees Name="John Peter" There are optional parameters in the 'FOR XML mode' clause. The XMLDATA option adds an XSD schema which describes the XML format of the result returned. The ELEMENTS options make the fields of the tables in the database to be returned as child elements. If the ELEMENTS option is not there the fields of the tables are returned as attributes instead of child elements of the XML document. The ELEMENTS option is allowed only in the AUTO mode. The BINARY BASE64 option is used to retrieve any binary data. The returned binary data is returned in BASE64 encoded format. The binary data can be retrieved in the RAW or EXPLICIT mode. An example of the RAW mode is given below: SELECT EmpName, EmpCity from EMP for XML RAW The above code returns a result like, row EmpName="John" EmpCity="New York" In the above result you can note that the fields of the resultset are returned as attributes of the element. .Net provides with managed classes for interacting with SQL Server. The managed classes of SQLXML provided by .Net are: · SqlXmlCommand - This is used to perform queries that are stored in XML documents which are also called XML templates. This class also provides support for client side XML processing. · SqlXmlParameter - this is used to provide parameterized values and is used along with SqlXmlCommand object. · SqlXmlAdapter - this is the adapter class for SQLXML provider. This is used to fill the dataset. · SqlXmlException - this is used to trap the error information from the SQL Server. A sample code using the managed classes is given below. For detailed information on the usage of the above managed classes you can refer to the MSDN documentation. static string cstr = "Provider=SQLOLEDB;Server=(local);database=EmpPersonal;";public static void testingSqlXml (){ Stream oStr = Console.OpenStandardOutput(); SqlXmlCommand sqlcmd = new SqlXmlCommand(cstr); sqlcmd.Root = "Employees"; sqlcmd.CommandType = SqlXmlCommandType.Sql; sqlcmd.CommandText = "SELECT EmpName, EmpCity FROM Employees FOR XML AUTO"; strm = sqlcmd.ExecuteToStream(oStr); oStr.Close();} Thus we have seen that SQLXML can be used to retrieve data directly from the SQL Server in XML format. It is easy to handle and transmit data through the internet if it is in the XML format and this can be easily achieved using the SQLXML. Want to stay current with the latest technology developments realted to XML. Visit Free XML Tutorial to get your FREE subscription now! ** Attention Webmasters / Website Owners ** You can reprint this article on your website as long as you do not modify any of the content, and include our resource box as listed above with all links intact and hyperlinked properly.
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 - WSJ The Wall Street Journal Tech That Will Change Your Life in 2024, From AI to EV - WSJ The Wall Street Journal The AI Gadget That Can Make Your Life Better—and Two That Definitely Won't The Wall Street Journal Want to Get More Done? That Podcast in the Background Is Holding You Back 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. - The Wall Street Journal OpenAI Made AI Videos for Us. These Clips Are Good Enough to Freak Us Out. The Wall Street Journal Apple's New iPad Pro vs. New iPad Air vs. iPad: Why Are There So Many? 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 iPhone Fixes to Make if You're the Family IT Department This Year The Wall Street Journal What Kind of Driver Will Your Kid Be? This Test Can Tell. 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 Apple's New Face Computer Is for Work The Wall Street Journal Hands Off! With $3500 Headsets in the Wild, New Social Norms Apply 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 100 Cool Tech Gadgets in 2024, According to a Tech Expert BestProducts.com 12 Apps We Can't Stop Using, for Better or Worse The Wall Street Journal 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 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 Ten years ago Microsoft bought Nokia's phone unit – then killed it as a tax write-off The Register Yes, It's Rude to Use Your Laptop During Meetings—and More Tech Etiquette Rules You Might Be Breaking The Wall Street Journal 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 EU duties might not hold off flood of China EVs The Register Why Tech Companies Are Not Your Friends: Lessons From Roku The New York Times 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
Is Desktop Search Deserving? Google, in their march to stay ahead of the pack of competition, has released Google Desktop Search. With Microsoft's MSN in the lead position and nipping at Google's heels, and Google's new shareholders to please, Google has more incentive than ever to deploy technology both better than the other guy's, and sooner. 10 Time Saving Keyboard Shortcuts Time is money. And when you constantly have to divide your time between your mouse and your keyboard, your workflow rate really slows down. Image Conversion In Computers JPEG, GIFF/JIFF, BMP, and TIFF are the most commonly used formats for storing still image files such as photographs, graphics, and drawings.JPEG stands for Joint Photographic Experts Group and is a standard for image compression. Palm PC critique I met an entrepreneur who hole heartedly disagree with an article in Advertising Age by Bradley Johnson that Palm Pilot can keep their market share through brand name. We discussed RIMM Research in Motion and my stock in that company and I defended the wireless venue, but he went into a tirade, luckily I used a digital recorder and got most of it; basically here is his critique:"That grip has already eroded by Palm PC makers and clones. How Does My PC Get Hot There are many sources of heat that can raise the temperature in your PC. No, I'm not talking about the Tabasco sauce you dripped over your keyboard when you ate that bowl of chili at your desk, and no, I'm not talking about that Pamela Anderson (or Ricky Martin poster, depending on your taste) above your desk. Why Build Your Own Computer System Have you ever thought about building your own computer system? Maybe you've heard friends talking about doing this sort of thing, but you were never sure what was involved. This article attempts to answer two questions. Your Affiliate Business - Peripherals, Software, Computers I have always been interested in computers, but in the beginning, I would not venture any further than to the software end of learning. However, learning only the software side, and knowing nothing about the hardware side, can open you up to some costly times at the shop. How To Increase Computer Speed And Performance - Great Tips & Tricks Many computer users are worried about their computer's performance. After spending lot of bucks, still they cannot have that charm of using PC as they had expected. 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. Troubleshooting Computer Freeze (Lockup) Problems How familiar does the following sound? Your computer was working fine, but then suddenly started locking up (aka hanging or freezing), rebooting itself (crashing) or shutting down spontaneously? If you know only too well what I am talking about, then read on! Performing the simple steps below can fix the majority of lockup cases.1. How to Place Home Theater Speakers You have your television and home theater receiver; you just bought your new speakers and subwoofer and are ready to test things out. It's time to break out the measuring tape because precision is vital to achieving the full potential of your home theater system. 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. Font Organizers Review, Part I Do you know how many fonts are currently installed on your PC? What is the difference between OpenType, TrueType, PostScript Type 1 and Printer fonts? If the answer is 'No', it's time to consider getting a font organizer.TypografThis extremely well-done 32-bit app lets you preview, print, and manage TrueType and Type 1 fonts. Help, I Need a New HDTV! (Part 4 of 5) Feeling overwhelmed in selecting a new TV? With all the choices these days, you may feel like, "Where do I start?!"In part 4 of our 5 part article, we the discuss "do I really need an HDTV?"---Right now, stations are moving towards HDTV programming. Although available for free over the air in major metropolitan areas, this process will take a few years to fully unfold. Printing Multiple Copies of Photos I do a holiday letter every year and send them to friends so they know what's happening with my family and I ask them about theirs. Though addressing the envelopes and such is a pain, I enjoy doing the letter and adding a wallet-sized photo of my kids to show them off. Quick System Restore with ASR Backups ASR (Automated System Recovery) is a feature available on the Windows XP Pro and Windows Server 2003 operating systems for quick and efficient system backup and restore.Typically, the restore process involves reinstalling the operating system and configuring all physical storage to their original settings before restoring data and settings. PC Tools Youd Never Think You Need Do you use Windows standard uninstall feature? How do you migrate data from your old PC to the new one? Get some tips on amazing software you never knew existed and find out why the pros have been using them for years.Ashampoo UnInstaller SuiteThe question is, why should this be necessary at all? Why do you need a special program? Why can't you just delete an application in the same way you can delete a file? The full answer to this question could fill a book. Basic Computer Maintenance One of the most common questions computer users ask is, "How do I maintain my computer and keep it running great?" A computer is a lot like a car?it costs more than you think it should, it starts going down in value as soon as you bring it home and it requires regular maintenance to keep it running smoothly. Here are a few basic guidelines required to help keep your PC out of the shop:?Always use a surge protector! Power surges, spikes, lightning and brown-outs are all things that can literally burn up your computer & its peripherals. How to Buy a Plasma Television Set Most people think that all you have to do to purchase a new plasma television set is to walk into a shop, look around, and purchase the first set that catches your attention. This is how you're supposed to do it, right? Wrong! Buying a television, whether it has a plasma monitor or a LCD monitor, takes careful planning. What Does That Error Message Really Mean? Surf the 'Net for about 10 minutes and chances rate veryhigh that you'll encounter an error of one kind oranother.Whether the error message pops up on your own computer oron a website loaded in your browser, knowing what theerror means can help you solve the problem much fasterand avoid hours of frustration (especially in a situationwhere nothing you do will solve the problem). |
home | site map |
© 2006 |