Thursday, August 12, 2010

How does Microsoft Surface work?

Microsoft Surface uses cameras and image recognition in the infrared spectrum to recognize different types of objects such as fingers, tagged items and shapes. This input is then processed by the computer and the resulting interaction is displayed using rear projection. The user can manipulate content and interact with the computer using natural touch and hand gestures, instead of a typical mouse and keyboard.

What are the key capabilities of Microsoft Surface?

Microsoft Surface has four key capabilities that make it such a unique experience:

* Direct interaction. Users can grab digital information with their hands and interact with content on-screen by touch and gesture – without using a mouse or keyboard.
* Multi-user experience. The large, horizontal, 30 inch display makes it easy for several people to gather and interact together with Microsoft Surface - providing a collaborative, face-to-face computing experience.
* Multi-touch. Microsoft Surface responds to many points of contact simultaneously - not just from one finger, as with a typical touch screen, but from dozens of contact points at once.
* Object recognition. Users can place physical objects on the screen to trigger different types of digital responses – providing for a multitude of applications and the transfer of digital content to mobile devices.

What is Microsoft Surface?

Microsoft Surface is a revolutionary multi-touch computer that responds to natural hand gestures and real-world objects, helping people interact with digital content in a simple and intuitive way. With a large, horizontal user interface, Surface offers a unique gathering place where multiple users can collaboratively and simultaneously interact with data and each other.

For Users: Microsoft Surface represents a fundamental change in the way we interact with digital content. Leave the mouse and keyboard behind. Surface lets you grab digital content with your hands and move information with simple gestures and touches. Surface also sees and interacts with objects placed on the screen, allowing you to move information between devices like mobile phones or cameras. The result is a fun, social and exciting computing experience like you’ve never had before.

For Businesses: Microsoft Surface provides tremendous potential for businesses to improve communication, and be more efficient in how they deliver information and services to their customers. The intuitive and approachable interface is easy to learn and the familiar software platform makes it easy to manage, too. The multi-touch and multi-user capabilities create an incredibly collaborative experience, where sharing and exploring information is easier than ever.

Learn about Microsoft Surface technical resources

Microsoft Surface is a new product and a new platform, and there are multiple resources that describe the various aspects of Surface. If you are new to Surface, start by visiting the following:

* What is Microsoft Surface?
* Getting Started in the Surface section of the TechNet Library
* Microsoft Surface Support is available on MSDN and TechNet
* Microsoft Surface Design and Development Training
For Developers

If you want to start developing, the following resources can help you set up your development environment and develop your first, basic Surface application.

* Surface SDK
This package includes the Microsoft Surface SDK 1.0 SP1 Workstation Edition installation file and documentation. The Surface SDK includes the APIs, documentation, and tools to help you develop Surface touch-enabled applications on your workstation. Before you download the Surface SDK, make sure you read the Setting Up a Development Environment article to learn about the hardware and software requirements for developing Surface applications on a workstation.

* Surface SDK Documentation in the MSDN Library
This documentation provides the latest information about how you can develop and design applications for the Surface software platform, including control-specific design guidelines, quick starts for creating WPF and XNA applications, How Do I...? examples that explain common Surface programming tasks, and sample applications that demonstrate multiple Surface programming techniques in a complete application.

* Related Technologies and Resources
This page describes tools and technologies that you might want to learn more about as you develop Surface applications, including Windows Presentation Foundation (WPF), XNA, and Expression Blend.

* Microsoft Surface Toolkit for Windows Touch Beta (NEW)
This beta package includes the advanced Microsoft Surface controls, templates, and samples to easily create applications that are optimized for multi-touch interaction and that run on Windows Touch PCs. With the .NET Framework 4.0, Windows Presentation Framework 4.0 (WPF), and this toolkit, Windows Touch developers can quickly and consistently create advanced multi-touch applications for Windows Touch PCs. This toolkit also provides a jump-start for Surface application developers to prepare for the next version of Microsoft Surface.
For Designers

Microsoft Surface presents some unique design challenges. To help you understand and solve these challenges, read the Microsoft Surface User Experience Guidelines. These guidelines are intended for designers, program managers, and developers of Surface applications to inform you about requirements and recommendations for designing great Surface applications.

* Microsoft Surface User Experience Guidelines



For IT Professionals

If you are managing one or more Surface units in a venue, you will need to understand the core administration tasks that you can perform with a Surface unit, including planning, configuring and deploying, monitoring, and troubleshooting. To learn about how to perform these tasks, see the following resource:

* Microsoft Surface section of the TechNet Library

This section also includes tools to help you administer Surface units and answers some frequently asked questions about the Surface hardware and software.

Hands on Microsoft Surface @ CES 2010

Microsoft Surface at CES 2010

Surface And Objects

Get Microsoft Silverlight

Microsoft Surface for Windows

Get Microsoft Silverlight


Microsoft Surface for Windows Touch Beta Announcement
The Microsoft Surface Toolkit for Windows Touch Beta is a set of controls, APIs, templates, sample applications and documentation currently available for Surface developers. With the .NET Framework 4.0, Windows Presentation Framework 4.0 (WPF), and this toolkit, Windows Touch developers can quickly and consistently create advanced multitouch experiences for Windows Touch PCs. This toolkit also provides a jump-start for Surface application developers to prepare for the next version of Microsoft Surface.

Wednesday, August 11, 2010

About Microsoft Surface

After establishing the lead in software industry, Microsoft toyed with various hardware. We saw xBox, Zune etc. Then a bigger project was under development under code name Milan, which was all about Microsoft Surface. Milan was aimed to leverage the perfect combination of hardware and software. Manipulating digital content using hand gestures, motions and physical objects is all about Microsoft Surface.
Many had a wrong impression about Microsoft Surface. They thought it is another glorified and hyped touch screen computer. And they are proved wrong by the features provided in the Microsoft surface. The touch screen computers enable users to do away with keyboard and mouse. They can navigate the menu by touching various options to reach a logical end of viewing data or printing. And there ends the comparison. Microsoft Surface can do many more things, which you think are not possible!What is so special about Microsoft Surface? One can touch a color in the one-screen palette and draw an image on the screen. Touch blue and draw the sky, Touch green and draw grass. Microsoft Surface can understand all this. It also recognizes various objects. The system can be designed to set up a plate on the surface and the system throws up a menu! And many more possibilities await us as we progress.


How can Microsoft Surface identify the fingers and objects? The technology itself is not new. It is called Multi-touch. University of Toronto had some pioneering work on multi-touch tablets and Bell Labs on multi-touch screens, way back in early 1980s. Steven Bathiche of Microsoft Hardware and Andy Wilson of Microsoft Research conceptualized leveraging multi-touch and thought about Microsoft Surface as product in 2001.


Microsoft formed a team in October 2001 to make Microsoft Surface a reality. The work went on briskly and a presentation about Microsoft Surface was given to Bill Gates in 2003. The first prototype was nicknamed T1 and the development team designed specific applications like photo browser, puzzles, games etc. After building more than 80 prototypes, the hardware design was frozen in 2005.Microsoft CEO Steve Ballmer unveiled Microsoft Surface on May 29, 2007 and the whole world came to know about Microsoft Surface. Microsoft has some partners like Starwood Hotels & Resorts Worldwide, International Game Technology , Harrah's Entertainment, T-Mobile etc readily willing to experiment Microsoft Surface in real world situation in their business.


The 30-inch screen brings on all the excitement about Microsoft Surface. This 22 inches high, 21 inches deep, 42 inches wide innovative product costs as much as US$ 10000 and it takes some time to be affordable to all. Probably in another 4-5 years, the surface becomes so common that, every house and business will have a Surface and think about Microsoft Surface as part of their furniture, which is intelligent!!

Welcome to Microsoft Surface. Experience together computing

Microsoft Surface also know as Microsoft Tabletop - The interactive tabletop computer, the surface that feels you

Microsoft Surface - Tabletop Computer. You won't believe this until you see it. It's actually real. No mouse, no keyboards, but you can touch it and guess what . . . it actually feels you. Don't you know what is it? It's Microsoft Surface!!!

This is the best place for you, either you are a big fan of Microsoft Surface or you are not. Here you can find out everything you need to know about Microsoft Surface, view Microsoft Surface photos, watch videos about Microsoft Surface, read articles about other products in competition with Microsoft Surface.

Learn more about Microsoft Surface

• Microsoft Surface Overview

• Experience Microsoft Surface

• The Origins of Microsoft Surface

• The Magic of Microsoft Surface

• The Power of Microsoft Surface

• The Possibilities of Microsoft Surface

Microsoft Surface - Is it really special?

What is so special about Microsoft Tabletop? One can touch a color in the one-screen palette and draw an image on the screen. Touch blue and draw the sky, Touch green and draw grass. Microsoft Tabletop can understand all this. It also recognizes various objects. The system can be designed to set up a plate on the surface and the system throws up a menu! And many more possibilities await us as we progress.

Many had a wrong impression about Microsoft Surface. They thought it is another glorified and hyped touch screen computer. And they are proved wrong by the features provided in the Microsoft Tabletop. The touch screen computers enable users to do away with keyboard and mouse. They can navigate the menu by touching various options to reach a logical end of viewing data or printing. And there ends the comparison. Microsoft Tabletop can do many more things, which you think are not possible!
The Features

There are four main components being important in it's interface: directinteraction, multi-touch contact, a multi-user experience, and object recognition. This device also enables drag and drop digital media when wi-fi enabled devices are placed on it such as a Microsoft Zune, cellular phones, or digital cameras. It features multi-touch technology, that enables multiple points of contact.

This technology allows non-digital objects to be used as input devices. This means that the source of information does not necessarily have to be digital in form.This is because,the technology does not rely on restrictive properties, such as the capacitance, electrical resistance, or temperature of the tool used

Direct interaction: Facility to manage digital information with hand gestures and touch instead on mouse and keyboard.

Multi-touch contact: User need not use only one finger to manage digital data. If user dips five fingers in five different colors in the on screen paint palette and draws five lines with five fingers, you get five lines with five colors . . 
Experience the Tabletop Computer

It is as significant a progress in user interface technology as the progress from DOS [Disk Operating System] to GUI [Graphic User Interface]. Many research reports prove that a large number of people are intimidated and isolated by today’s technology. Many features available in mobile phones, personal computers and other electronic devices like digital cameras aren’t even used because the people aren’t as aware of the features and benefits as they should be or they aren’t as comfortable with the technology to enjoy those features. . 

List of my favorite tools

List of my favorite tools:
Page Rank

Rank Checker (Ranking Tool) - Get a overview of your website's ranking

PageRank Lookup (PageRank Lookup - SEO Tools - Search Engine Optimization, Google Optimization) - check the PageRank for a website

Google PageRank Prediction (PageRank Prediction - Predict Page Rank Predictor) - check predicted PR of a site

Multi-Rank Checker (Rank Checker) - View your Google PageRank and Alexa Ranking in bulk

PageRank Checker (PageRank Checker - Check Your Google Page Rank) - View your Google PageRank on different Google servers

Links related

Reciprocal Link Check (Reciprocal Link Checker) - check whether your link partners are linking back to your website

Link Popularity Checker (LinkWorth | LinkQuote - Text Link Quote) - a popularity score given to a website based on inbound links

LinkPrice Lookup (LinkWorth | LinkQuote - Text Link Quote) - check the price of your link
Link Price Calculator (Link Price Calculator) - another tool for checking the price of links

Link Checker (http://www.ranks.nl/cgi-bin/ranksnl/tools/checklink.pl) - check your links to see if it's still valid or not

Link Popularity (Link Popularity - SEO Tools - Search Engine Optimization, Google Optimization) - checks the total number of web pages which link to a website

Link Price Calculator (Link Price Calculator - SEO Tools - Search Engine Optimization, Google Optimization) - help to determine the approximate amount you should be paying (or charging) per month for a text link (ad) from each and every page of the specified website

Site Link Analyzer (Site Link Analyzer - SEO Tools - Search Engine Optimization, Google Optimization) - analyze a given web page and return a table of data containing columns of outbound links and their associated anchor text

URL Rewriting (URL Rewriting - SEO Tools - Search Engine Optimization, Google Optimization) - convert dynamic URLs into static looking HTML URLs

Link Extractor (Link Extractor) - Extract links from a specific web page

Link Shortener (Link Shortener - Short/Shortcut Link - Hits Counter) - shorten a web address

Backlink Anchor Text Analyzer (http://www.webconfs.comURLnchor-text-analysis.php) - check link text used by your backlinks to Link to your website

Keyword related

Keyword Verification (Search Engine Placement Check - Marketleap Search Engine Verification Tool) - checks to see if your site is in the top three pages of a search engine result for a specific keyword

Keyword Density Analyser (Mark Horrell - Keyword density analyser) - another SEO tools for keywords

Keyword Cloud (Keyword Cloud - SEO Tools - Search Engine Optimization, Google Optimization) - a visual representation of keywords used on a website

Keyword Density (Keyword Density - SEO Tools - Search Engine Optimization, Google Optimization) - another SEO tool for checking keyword density

Keyword Difficulty Check (Keyword Difficulty Check - SEO Tools - Search Engine Optimization, Google Optimization) - see how difficult it would be to rank for specific keywords or phrases

Keyword Optimizer (Keyword Optimizer - SEO Tools - Search Engine Optimization, Google Optimization) - optimizer your keywords with this tool

Keyword Suggestion (Keyword Suggestion Tool) - Find related keywords matching your search


Sitemap

XML-Sitemaps (Create your Google Sitemap Online - XML Sitemaps Generator) - Build your Site Map online (XML, ROR, Text, HTML)

Gsitecrawler (Google Sitemap Generator for Windows :: GSiteCrawler) - Google (and Yahoo!) Sitemap Generator for Windows

Validate XML Sitemap (Google XML Sitemap Validator - XML Sitemaps Generator) - Search Engine Optimizion Tool for validating your xml sitemaps

Search Engines

Google Analytics (http://www.google.com/analytics/) - tells you everything about your visitors

Google Banned Checker (http://www.iwebtool.com/google_banned) - check whether a site is banned by Google or not

Search Engine Bot Simulator (http://www.xml-sitemaps.com/se-bot-simulator.html) - SEO Tool to simulate search engine parsing of webpages and display discovered links.

Indexed pages (http://www.seochat.com/seo-tools/indexed-pages/) - check the no. of indexed pages for your blog

Spider Simulator (http://www.seochat.com/seo-tools/spider-simulator/) - simulates a search engine by displaying the contents of a web page

Search Engine Friendly Redirect Checker (http://www.seochat.com/seo-tools/redirect-check/) - checks the exact HTTP headers that a web server is sending with an HTTP response.

Search Engine Position (http://www.iwebtool.com/search_engine_position) - Locate your search listings on Google and Yahoo!

Search Listings Preview (http://www.iwebtool.com/search_listings_preview) - Preview your website on Google, MSN and Yahoo! Search

HTML related

HTML Encrypt (http://www.iwebtool.com/html_encrypter) - Hide your HTML source code

HTML Optimizer (http://www.iwebtool.com/html_optimizer) - Optimize and clean your HTML source code

HTTP Headers (http://www.iwebtool.com/http_headers) - Extract the HTTP Headers of a web page

HTTP Headers Viewer (http://www.xml-sitemaps.com/http-headers-viewer.html) - check HTTP headers for any specific URL

Meta-tags Extractor (http://www.iwebtool.com/metatags_extractor) - Extract meta-tags information from a web page

Meta-tags Generator (http://www.iwebtool.com/metatags_generator) - Generate and configure your meta-tags

META Analyzer (http://www.seochat.com/seo-tools/meta-analyzer/) - analyze a website's meta tags

Meta Tag Generator (http://www.seochat.com/seo-tools/meta-tag-generator/) - help you to generate meta tags

Source Code Viewer (http://www.iwebtool.com/code_viewer) - View the source code of a page

Domain related

Alexa Traffic Rank (http://www.iwebtool.comURLlexa_traffic_rank) - View and compare Alexa Ranking graphs

Domain Age Tool (http://www.webconfs.com/domain-age.php) - find out the age of your competitor's domains

Domain Stats Tool (http://www.webconfs.com/domain-stats.php) - get all kind of statistics of your competitor's domains

Domain Availability (http://www.iwebtool.com/domain_availability) - Check the availability of domains

Domain Look-up (http://www.iwebtool.com/domain_lookup) - Retrieve a range of information about a domain

Domain Whois (http://www.iwebtool.com/whois) - Retrieve domain whois information

Instant Domain Checker (http://www.iwebtool.com/instant) - Check the availability of domains instantly

Ping Test (http://www.iwebtool.com/ping) - Check the presence of an active connection

Reverse IP/Look-up (http://www.iwebtool.com/reverse_ip) - Resolve a host to an IP address

Server Status (http://www.iwebtool.com/server_status) - Check if your website is online or offline

Website Speed Test (http://www.iwebtool.com/speed_test) - Find out how fast your website loads

What Is My IP Address (http://www.whatismyipaddress.com/) - shows your ip address

IP to City (http://www.webconfs.com/ip-to-city.php) - determine the Country, City, Latitude and Longitude of an IP Address

Website to Country (http://www.webconfs.com/website-to-country.php) - determine the Country in which the specified website is Hosted

Web stats

Statcounter (http://www.statcounter.com/) - famous free web tracker

HiStats (http://www.histats.com/) - Free, real time updated web stats service

Addfreestats (http://www.addfreestats.com/) - provide free website statistics

Miscellaneous

FEED Validator (http://www.feedvalidator.org/) - for Atom and RSS

W3C Markup Validation Service (http://validator.w3.org/) - check for conformance to W3C Recommendations and other standards

Kontera Ads Preview (http://www.webconfs.com/kontera-preview-tool.php) - preview Kontera Ads on your website

Online spell checker (http://www.markhorrell.com/tools/spellcheck.asp) - simple online spell checking tools

Browser Screen Resolution Checker (http://www.markhorrell.com/tools/browser.shtml) - shows what your site looks like with different screen resolutions

Your Browser Details (http://www.iwebtool.com/browser_details) - View your IP address and your browser details

Anonymous Emailer (http://www.iwebtool.comURLnonymous_emailer) - Send e-mails to users anonymously

md5 Encrypt (http://www.iwebtool.com/md5) - Encrypt text to MD5

Online Calculator (http://www.iwebtool.com/online_calculator) - A simple online calculator

Google

1. Reporting Spam to Google - http://www.google.com/contact/spamreport.html

2. Use Google to search your website - http://www.google.com/services/free.html

3. Submit your website to Google - http://www.google.com/addurl.html

4. Monitor Keyword Phrases - http://google.com/webalerts (This is neat to check out however does not help that much)

5. Googles Guidelines for Websmasters –

http://www.google.com/webmasters/guidelines.html (A must read new people)

6. Facts for Webmasters - http://www.google.com/webmasters/facts.html

7. Having Trouble? Contact Google Directly - http://www.google.com/ads/offices.html

Website Design & Tools

1. Free Forms for your website TFMail - http://nms-cgi.sourceforge.net/

2. Validate Your HTML - http://validator.w3.org/

3. HTTP Error Code Meanings - http://www.searchengineworld.com/val...errorcodes.htm (http://www.searchengineworld.com/val...errorcodes.htm)

4. Keyword Tracking - http://www.digitalpoint.com/tools/keywords/

5. Link Checker - http://dev.w3.org/cvsweb/~checkout~/...0charset=utf-8
(http://dev.w3.org/cvsweb/%7Echeckout...0charset=utf-8)

6. Search Engine Relationship Chart - http://www.bruceclay.com/searchengin...nshipchart.htm (http://www.bruceclay.com/searchengin...nshipchart.htm)
Bruce Clay does an excellent job of keeping this updated.

7. Link Popularity Checker (Uptime Bot) - http://www.uptimebot.com/

8. Character Counting - http://a1portal.com/freetools/charcount.htm (This is great when optimizing your title or meta tags)

9. Character Encoding - http://www.itnews.org.uk/w_qrefs/w_i...p_charsets.cfm (http://www.itnews.org.uk/w_qrefs/w_i...p_charsets.cfm) (Ever wonder what those iso-8859-4 or utf-8 were or how to use them?)

10. Converting Hex to Dec or Vice Versa - http://www.hypersolutions.org/pages/hex.html#DectoHex

11. Ascii-Dec-Hex Conversion Code Chart - http://www.sonofsofaman.com/misc/ascii/default.asp

12. Ascii-HTML View Conversion Chart - http://a1portal.com/freetools/asciicodes.htm (This is an excellent resource when placing ascii code on your website. Remember to use the correct character encoding)

13. Ascii Chart in .GIF Format - http://www.jimprice.com/ascii-0-127.gif

14. Customer Focus Tool - http://www.futurenowinc.com/wewe.htm (Tells you whether your website is focused on your customers or not)

15. Dead Link Checker - http://www.dead-links.com/ (Doesn't crawl links within Frames or JavaScript)

16. Adsense Simulator - http://www.digitalpoint.com/tools/adsense-sandbox/ (This will give you an idea of what ads will be displayed on your website before you place them)

17. Google Page Rank Calculator - http://www.webworkshop.net/pagerank...lator.php3?pgs= (This is an advanced tool for finding out what you need to get your PR to the next level.)

18. Page Rank Finder - http://www.seo-guy.com/seo-tools/google-pr.php (This is a great tool to find quality websites with the PR that you are looking for to exchange websites with. This tool only looks at the home page not the link pages. This tool looks at 10 pages or 100 results)

19. Future Google PR - http://www.searchengineforums.com/ap...e/type:rphans/ (http://www.searchengineforums.com/ap...e/type:rphans/) - This is an article that tells you what datacenter your Google PR is updated on first.

20. Keyword Analysis Tool - http://www.mcdar.net/ - This tool is a must. It's quick and easy to use

21. Keyword Density Analyzer - http://www.webjectives.com/keyword.htm

22. Keyword Difficulty Checker - http://www.searchguild.com/cgi-bin/difficulty.pl (You will need a Google API for this one)

23. Free Google API - http://www.google.com/api

24. Rocket Rank - http://www.rocketrank.com/ - This will only check the top 20 of the following SE's:
(All The Web DMOZ AltaVista Overture Excite Web Crawler HotBot Lycos What U Seek Yahoo)

Keyword Suggestion Tools:

25. WordTracker & Overture Suggestions http://www.digitalpoint.com/tools/suggestion/ - This is the best one of the three

26. Adwords Suggestion - https://adwords.google.com/select/m...=KeywordSandbox

27. Overture Suggestion - http://inventory.overture.com/d/sea...ory/suggestion/

28. Link Analyzer - http://www.scribbling.net/analyze-web-page-links Analyze the ratio of internal links vs. external links. This is a good tool when determining page rank leakage.

29. Link Appeal - http://www.webmaster-toolkit.com/link-appeal.shtml (Want to know whether or not you actually want your link on that page?)

30. Link City - http://showcase.netins.net/web/phdss/linkcity/ (This place has EVERY tool under the sun for everything you could ever possibly want)

31. Link Reputation - http://198.68.180.60/cgi-bin/link-reputation-tool.cgi (Reveals baclinks pointing to the target URL along with a link survey for each backlink.)

32. Google PR Tools - http://www.thinkbling.com/tools.php (This guy has tons of fantastic tools. He is not as popular as some of the rest yet the tools are great)

33. Protect Your e-mail address - http://www.fingerlakesbmw.org/main/flobfuscate.php (Obfuscates your e-mail so spambots don't pick it up from the Internet)

34. Digital Points Ad Network - http://www.digitalpoint.com/tools/ad-network/?s=2197 - After using all of the tools and more on this page. This has helped out the rankings faster than anything else.

35. Sandbox Detection Tool - http://www.socengine.com/seo/tools/sandbox-tool.php - Is your website being sandboxed?

36. Spider Simulation - http://www.submitexpress.com/analyzer/ - See what the spider sees on your website

37. SEO-Toys - http://seo-toys.com/ - These are some things that I had in my favorites. Some of them are okay.

38. Multiple SEO Tools - http://www.free-seo-tools.com/ - This website has a variety of misc. tools on it that you can use to better your search engine rankings.

39. Bot Spotter - http://sourceforge.net/projects/botspotter - This is a phenomenal script that will track what bots hit your website at what times. (Runs on PHP enabled websites)

40. Net Mechanic - http://www.netmechanic.com/toolbox/power_user.htm - This will break your website down and tell you any errors that you may be unaware of.

41. Statcounter - http://www.statcounter.com/ - This will track your clients throughout the dynamically created pages of your website. This is a free service.

42. Dr. HTML - http://www.fixingyourwebsite.com/drhtml.html - This will test your website for any errors that you may be unaware of and tell you how to fix them.

43. Page Rank Calculation - http://www.sitepronews.com/pagerank.html

Newsletters & Articles

1. Site Pro News - www.sitepronews.com (http://www.sitepronews.com/)

2. In Stat - http://www.instat.com/ (This has some decent insight)

3. Page Rank Explained - http://www.webworkshop.net/pagerank....olbar_pagerank (http://www.webworkshop.net/pagerank....olbar_pagerank)

4. Seach Engine Ratings and Reviews - http://searchenginewatch.com/reports/

5. Database of Robots - http://www.robotstxt.org/wc/active/html/index.html
(Ever wondered anything about the spiders that are out there?)

ISAPI Rewrites

1. URL Replacer - (Free) - http://www.motobit.com/help/url-repl...od-rewrite.asp (http://www.motobit.com/help/url-repl...od-rewrite.asp)

2. Mod Rewrite2 - ($39.90US) - http://www.iismods.com/url-rewrite/index.htm

3. URL Rewrite - (23.00EUR) - http://www.smalig.com/url_rewrite-en.htm

Link Exchanging

1. Links Manager ($20.00US /mo)- http://linksmanager.com/cgi-bin/cook/control_panel.cgi (This is great for the beginner however you will find out that you need to majorly adjust your pages manually in order to spread page rank throughout them otherwise you end up with 20 pages with no PR and 1 page with PR.)

2. Page Rank Finder - http://www.seo-guy.com/seo-tools/google-pr.php

3. Link Appeal - http://www.webmaster-toolkit.com/link-appeal.shtml

Search Engine Submissions

1. Submit Express - http://www.submitexpress.com/newsletters/dec_15_00.html (A lot of people utilize this service. I don't utilize it)

2. Alexa - http://pages.alexa.com/help/webmaste...tml#crawl_site (http://pages.alexa.com/help/webmaste...tml#crawl_site)

3. AOL - http://search.aol.com/aolcom/add.jsp

4. DMOZ Dummies Guide - http://www.dummies-guide-to-dmoz.or..._not_google.htm (http://www.dummies-guide-to-dmoz.or..._not_google.htm/)

5. DMOZ Instructions - http://dmoz.org/add.html

6. DMOZ Resource Forum - http://resource-zone.com/forum/showthread.php?t=396 (This is where you go when your website doesn't show up in DMOZ after you have submitted READ THEIR RULES FOR ASKING)

7. ExactSeek - http://www.exactseek.com/freemember.html

8. Google - http://www.google.com/addurl.html

9. Yahoo http://submit.search.yahoo.com/free/request (You must have an account)

10. Yahoo Directory Help - http://docs.yahoo.com/info/suggest/appropriate.html

11. Yahoo Express Submit TOS - https://ecom.yahoo.com/dir/express/terms

12. Yahoo Submit Help - http://help.yahoo.com/help/us/dir/su...uggest-01.html (http://help.yahoo.com/help/us/dir/su...uggest-01.html)

13. MSN - http://beta.search.msn.com/docs/submit.aspx?

ALink Reciprocal Link Checker (http://www.info-pack.com/alink/)

AMeta Meta Tag Editor (http://www.info-pack.com/ameta/)

XML Sitemap Maker (http://www.xmlsitemapmaker.com/)
RSS Feed Maker (http://www.rssfeedmaker.biz/)

Webpage Size Checker (http://www.info-pack.com/pagesize/)

Google's new Search-based Keyword Tool to the list, its hotness: http://www.google.com/sktool/#

Basic SEO practices for newbies

I've been recieving a few PMs lately along the lines of this one.

Quote:
Hey safil over the last couple of days you've answered some questions I had about SEO with great ease. I was wondering if you do any kind of SEO consulting with people trying to become familiar with SEO??
The answer is "not really". I'm not even close to being some kind of SEO guru, the questions I've been answering lately are all just pretty basic.

There are a lot of people better at SEO than me, so if you want a consultant you should try checking in the BST services threads. In fact I purchase services from the BST threads myself. If you do your due diligence before choosing a service provider, I've found that the sellers here on bhw are some of the best anywhere.

So, rather than keep answering individual PMs, I'll just make this thread and send them here from now on.

Basic SEO practices for newbies:

The thing to remember is that SEO isn't a magic bullet. It's important, but no one knows the exact algorithms the SEs use, and each one is different so all you can do is optimize the best you can. There happens to be a few things that you should just always do whenever you make a new website. Don't stress over every little thing, just make sure you are doing it, this should just become kind of automatic for you.

Make sure you fill in your meta tags with a good title, description, and the right keywords. I personally don't think the keywords meta-tag is nearly as important as everyone else on here does, but it gives me a way to organize my keywords list for me to reference. When you start having many different websites, it's good to include whatever notes to yourself you can. When you come back to work on an older site you might not remember eveything you were thinking before. The metatags help you remember your site info as much as it helps the SE figure it out. A good rule of thumb is that anything that won't hurt you for SEO and might help, you should use and use correctly. Definately use the title meta-tag, try to include keywords in the title. Definately use the description meta-tag, google will normally use this for the summary it displays in the listing. It isn't used for indexing so write it for humans, this is what gets people to click on your link when they see it in the SERP. Don't use the same metatags for every page on your site. Take the time to make them be specific to each page.

Create good content. Make sure you have some decent content. Content is what the internet was invented for. If you have unique and quality content, then all the seo and backlinking you're doing is just to get the ball rolling. Give them what they want, show them where it is, and they'll start coming. If it's good enough then it'll eventually start building on its own naturally because people like what they found. That's the idea anyway. So whenever possible use the best page design and the best content possible. Avoid duplicate content between different pages on your site, the SE will most likely penalize your site for that.

Remember, your content isn't just something to get google to like your site, it is the whole point of your site. The content and how you structure it is what will make visitors do what you want when they get there. If it's crap they'll just leave, and 99% of them won't leave by clicking on your adsense or affilliate link, they'll just close the window or use the back button. (yes, of course if your doing blackhat stuff you can make the browser go where you want, but that's for a different discussion.)

Include your keywords. Structure your content correctly, make a few title headers in the content that include keywords (use header tags h1, h2, etc.), try to have a keyword density around 2% in your content, and maybe 4% for the whole page including the metatags, alt tags, anchors, etc.

Be sure that your .htaccess is set up correctly. Decide on which way you want your url to be and stick with it. If you decide to use www then always use it like that in your links, don't use both. I usually set up a 301 for all www requests to redirect to non-www urls. If you don't set that up then every single page on your site can appear to google as having at least one duplicate. If that's the only thing wrong on your site it isn't going to kill you, but it's so easy to fix. If you don't know how to set up a redirect in your .htaccess file then just do a search, there are many other threads explaining it. Check google if you can't find it here. Also, .htaccess only apples if your on an Apache server, Windows servers do it a little differently, if that applies to you then just search google to find out how to do it. If your consitent in your linking, then the only time the redirect will come into play is if you get natural backlinks that you have no control over. You should also specify which you prefer, www or not-www in google tools if you use it. (If you don't then you really should, I recommend you set yourself up an account for webmaster tools and analytics.)

Make a robots.txt file and I like to include a favicon because without them the robots will trigger file not found errors on your server. Be sure to configure your robots.txt correctly. Make a custom 404 page. If your site has more than just a couple of pages then also create a sitemap.xml file. It's not a bad idea to just create a sitemap anyway no matter what, it lets you define the structure of your site to the crawlers. Just search google if you don't know how to do any of that, it's very basic and you can find exact instructions within a minute when you do a search.

Other than that there isn't a lot more you can do for on-site SEO. When people ask about SEO they're always thinking of on-site SEO, but thats the easy and quick part. Just do it and get on with it.

Everything else is off-site SEO and involves building backlinks and promotion.
This is where you need to focus your efforts. This is where the magic bullet is, if there really is one.

Social Bookmarks, Directory Submissions, Profile Links, and Blog Comments are really the easiest place to start getting backlinks. It's not a bad idea to purchase these links from a service. They are easy to make, but to do it right they really need to be posted from many different accounts and ip adresses. A good idea when your starting is to do it yourself a little bit to see how it works, then purchase larger quantities from a service. You want to get a lot of links, but you don't want to over do it. Building to fast can look unnatural, just do some searches and read up on it a little more. How many and how fast is a judgement call you have to make. hold off on more complex linkbuilding until you have a little more experience. Linkwheels and other link structures can be very powerful, but can also hurt your site a lot if not done correctly.

Whenever possible include keyword anchors and title or alt tags on your backlinks. Don't always use the same anchors, vary it up a little, use 3 or 4 different keywords and even do a few with some non keyword anchors. You are trying to look as though a lot of different real people have taken a liking to your site, if it were natural then all links wouldn't be exactly the same, so you want to simulate that same type of randomness. Backlinking strategies are all about simulating the natural events that happen as a site grows in popularity. If you can do it successfully then the SE's will give you good position in the listings, and then hopefully what you are simulating can become reality. The point of all of it is to get traffic.

Change up your anchor text. The idea of backlinking is to simulate that masses of people are becoming interested in your site. It should have some amount of randomness to it in order to look natural. I've seen a few made up stats on what's best, but I think a good rule of thumb is maybe about 45% primary keywords, 35% secondary keywords, and about 15% random unrelated like Click Here, and then about 5% just the url. The exact percentage isn't dramatically important, it just needs to seem like the linking is natural.

Create relevant articles containing your keywords, include backlinks using keyword anchors, and submit to article directories. Article directories are mostly authority sites and your article becomes a relevant backlink to your site. Then create profiles and accounts on blogs, social networking sites, forums etc. Include a link to your website whenever you do that and each one of those become backlinks as well.

Thats the end of it. Well kinda.
Go back and watch your stats to see what keywords are getting the most traffic to your site, analyze the data a little bit and if you need to, remove or add keywords to your content and tags, and adjust the anchors your using in your backlinks.

Continue building links. Remember you're trying to artificially create the appearance to the SE that your site is popular. When that happens naturally, people are always adding new links to your site. Since you are trying to look natural you have to do the same thing. Linkbuilding never stops completely.

OK, there you go. That's that basics of SEO. Everything else is about fine tuning, and has to be looked at for each individual situation.

If you have any more questions, before you start PMing anyone just read through the threads in the White Hat SEO section, and do some searching on google. You can find some really good information from some much smarter people than me.

If there are any SEO gurus that want to expand on this or if you see any errors you think should be discussed, please add your input.

Hope this can help some of you.

Tuesday, August 10, 2010

Lesson 07: Using Stored Procedures

This lesson shows how to use stored procedures in your data access code.  Here are the objectives of this lesson:
  • Learn how to modify the SqlCommand object to use a stored procedure.
  • Understand how to use parameters with stored procedures. 

Introduction

A stored procedures is a pre-defined, reusable routine that is stored in a database.  SQL Server compiles stored procedures, which makes them more efficient to use.  Therefore, rather than dynamically building queries in your code, you can take advantage of the reuse and performance benefits of stored procedures.  The following sections will show you how to modify the SqlCommand object to use stored procedures.  Additionally, you'll see another reason why parameter support is an important part of the ADO.NET libraries.

Executing a Stored Procedure

In addition to commands built with strings, the SqlCommand type can be used to execute stored procedures.  There are two tasks require to make this happen: let the SqlCommand object know which stored procedure to execute and tell the SqlCommand object that it is executing a stored procedure.  These two steps are shown below:
// 1.  create a command object identifying
 //     the stored procedure
 SqlCommand cmd  = new SqlCommand(
  "Ten Most Expensive Products", conn);

 // 2. set the command object so it knows
 //    to execute a stored procedure
 cmd.CommandType = CommandType.StoredProcedure;
While declaring the SqlCommand object above, the first parameter is set to "Ten Most Expensive Products".  This is the name of a stored procedure in the Northwind database.  The second parameter is the connection object, which is the same as the SqlCommand constructor used for executing query strings.
The second command tells the SqlCommand object what type of command it will execute by setting its CommandType property to the StoredProcedure value of the CommandType enum.  The default interpretation of the first parameter to the SqlCommand constructor is to treat it as a query string.  By setting the CommandType to StoredProcedure, the first parameter to the SqlCommand constructor will be interpreted as the name of a stored procedure (instead of interpreting it as a command string).  The rest of the code can use the SqlCommand object the same as it is used in previous lessons.

Sending Parameters to Stored Procedures

Using parameters for stored procedures is the same as using parameters for query string commands.  The following code shows this:
// 1.  create a command object identifying
 //     the stored procedure
 SqlCommand cmd  = new SqlCommand(
  "CustOrderHist", conn);

 // 2. set the command object so it knows
 //    to execute a stored procedure
 cmd.CommandType = CommandType.StoredProcedure;

 // 3. add parameter to command, which
 //    will be passed to the stored procedure
 cmd.Parameters.Add(
  new SqlParameter("@CustomerID", custId));
The SqlCommand constructor above specifies the name of a stored procedure, CustOrderHist, as its first parameter.  This particular stored procedure takes a single parameter, named @CustomerID.  Therefore, we must populate this parameter using a SqlParameter object.  The name of the parameter passed as the first parameter to the SqlParameter constructor must be spelled exactly the same as the stored procedure parameter.  Then execute the command the same as you would with any other SqlCommand object.

A Full Example

The code in Listing 1 contains a full working example of how to use stored procedures.  There are separate methods for a stored procedure without parameters and a stored procedure with parameters.
Listing 1: Executing Stored Procedures
using System;
using System.Data;
using System.Data.SqlClient;

class StoredProcDemo
{
 static void Main()
 {
  StoredProcDemo spd = new StoredProcDemo();

  // run a simple stored procedure
  spd.RunStoredProc();

  // run a stored procedure that takes a parameter
  spd.RunStoredProcParams();
 }

 // run a simple stored procedure
 public void RunStoredProc()
 {
  SqlConnection conn = null;
  SqlDataReader rdr  = null;

  Console.WriteLine("\nTop 10 Most Expensive Products:\n");

  try
  {
   // create and open a connection object
   conn = new 
    SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
   conn.Open();

   // 1.  create a command object identifying
   //     the stored procedure
   SqlCommand cmd  = new SqlCommand(
    "Ten Most Expensive Products", conn);

   // 2. set the command object so it knows
   //    to execute a stored procedure
   cmd.CommandType = CommandType.StoredProcedure;

   // execute the command
   rdr = cmd.ExecuteReader();

   // iterate through results, printing each to console
   while (rdr.Read())
   {
    Console.WriteLine(
     "Product: {0,-25} Price: ${1,6:####.00}",
     rdr["TenMostExpensiveProducts"],
     rdr["UnitPrice"]);
   }
  }
  finally
  {
   if (conn != null)
   {
    conn.Close();
   }
   if (rdr != null)
   {
    rdr.Close();
   }
  }
 }

 // run a stored procedure that takes a parameter
 public void RunStoredProcParams()
 {
  SqlConnection conn = null;
  SqlDataReader rdr  = null;

  // typically obtained from user
  // input, but we take a short cut
  string custId = "FURIB";

  Console.WriteLine("\nCustomer Order History:\n");

  try
  {
   // create and open a connection object
   conn = new 
    SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
   conn.Open();

   // 1.  create a command object identifying
   //     the stored procedure
   SqlCommand cmd  = new SqlCommand(
    "CustOrderHist", conn);

   // 2. set the command object so it knows
   //    to execute a stored procedure
   cmd.CommandType = CommandType.StoredProcedure;

   // 3. add parameter to command, which
   //    will be passed to the stored procedure
   cmd.Parameters.Add(
    new SqlParameter("@CustomerID", custId));

   // execute the command
   rdr = cmd.ExecuteReader();

   // iterate through results, printing each to console
   while (rdr.Read())
   {
    Console.WriteLine(
     "Product: {0,-35} Total: {1,2}",
     rdr["ProductName"],
     rdr["Total"]);
   }
  }
  finally
  {
   if (conn != null)
   {
    conn.Close();
   }
   if (rdr != null)
   {
    rdr.Close();
   }
  } 
 }
}
The RunStoredProc method in Listing 1 simply runs a stored procedure and prints the results to the console.  In the RunStoredProcParams method, the stored procedure used takes a single parameter.  This demonstrates that there is no difference between using parameters with query strings and stored procedures.  The rest of the code should be familiar to those who have read previous lessons in this tutorial.

Summary

To execute stored procedures, you specify the name of the stored procedure in the first parameter of a SqlCommand constructor and then set the CommandType of the SqlCommand to StoredProcedure.  You can also send parameters to a stored procedure by using SqlParameter objects, the same way it is done with SqlCommand objects that execute query strings.  Once the SqlCommand object is constructed, you can use it just like any other SqlCommand object as described in previous lessons.

Your feedback and constructive contributions are welcome.  Please feel free to contact me for feedback or comments you may have about this lesson.

Lesson 06: Adding Parameters to Commands

his lesson shows you how to use parameters in your commands.  Here are the objectives of this lesson:
  • Understand what a parameter is.
  • Be informed about the benefits of using parameters. 
  • Learn how to create a parameter.
  • Learn how to assign parameters to commands.

Introduction

When working with data, you'll often want to filter results based on some criteria.  Typically, this is done by accepting input from a user and using that input to form a SQL query.  For example, a sales person may need to see all orders between specific dates.  Another query might be to filter customers by city.
As you know, the SQL query assigned to a SqlCommand object is simply a string.  So, if you want to filter a query, you could build the string dynamically, but you wouldn't want to.  Here is a bad example of filtering a query.
// don't ever do this!
 SqlCommand cmd = new SqlCommand(
  "select * from Customers where city = '" + inputCity + "'";
Don't ever build a query this way!  The input variable, inputCity, is typically retrieved from a TextBox control on either a Windows form or a Web Page.  Anything placed into that TextBox control will be put into inputCity and added to your SQL string.  This situation invites a hacker to replace that string with something malicious.  In the worst case, you could give full control of your computer away.
Instead of dynamically building a string, as shown in the bad example above, use parameters.  Anything placed into a parameter will be treated as field data, not part of the SQL statement, which makes your application much more secure.
Using parameterized queries is a three step process:
  1. Construct the SqlCommand command string with parameters.
  2. Declare a SqlParameter object, assigning values as appropriate.
  3. Assign the SqlParameter object to the SqlCommand object's Parameters property.
The following sections take you step-by-step through this process.

preparing a SqlCommand Object for Parameters

The first step in using parameters in SQL queries is to build a command string containing parameter placeholders.  These placeholders are filled in with actual parameter values when the SqlCommand executes.  Proper syntax of a parameter is to use an '@' symbol prefix on the parameter name as shown below:
// 1. declare command object with parameter
 SqlCommand cmd = new SqlCommand(
  "select * from Customers where city = @City", conn);
In the SqlCommand constructor above, the first argument contains a parameter declaration, @City.  This example used one parameter, but you can have as many parameters as needed to customize the query.  Each parameter will match a SqlParameter object that must be assigned to this SqlCommand object.

Declaring a SqlParameter Object

Each parameter in a SQL statement must be defined.  This is the purpose of the SqlParameter type.  Your code must define a SqlParameter instance for each parameter in a SqlCommand object's SQL command.  The following code defines a parameter for the @City parameter from the previous section:
// 2. define parameters used in command object
 SqlParameter param  = new SqlParameter();
 param.ParameterName = "@City";
 param.Value         = inputCity;
Notice that the ParameterName property of the SqlParameter instance must be spelled exactly as the parameter that is used in the SqlCommand SQL command string.  You must also specify a value for the command.  When the SqlCommand object executes, the parameter will be replaced with this value.

Associate a SqlParameter Object with a SqlCommand Object

For each parameter defined in the SQL command string argument to a SqlCommand object, you must define a SqlParameter.  You must also let the SqlCommand object know about the SqlParameter by assigning the SqlParameter instance to the Parameters property of the SqlCommand object.  The following code shows how to do this:
// 3. add new parameter to command object
 cmd.Parameters.Add(param);
The SqlParameter instance is the argument to the Add method of the Parameters property for the SqlCommand object above.  You must add a unique SqlParameter for each parameter defined in the SqlCommand object's SQL command string.

Putting it All Together

You already know how to use SqlCommand and SqlDataReader objects.  The following code demonstrates a working program that uses SqlParameter objects.  So, everything should be familiar by now, except for the new parts presented in this article:
Listing 1: Adding Parameters to Queries
using System;
using System.Data;
using System.Data.SqlClient;

class ParamDemo
{
 static void Main()
 {
  // conn and reader declared outside try
  // block for visibility in finally block
  SqlConnection conn   = null;
  SqlDataReader reader = null;

  string inputCity = "London";

  try
  {
   // instantiate and open connection
   conn =  new 
    SqlConnection("Server=(local);DataBase=Northwind;Integrated Security=SSPI");
   conn.Open();

   // don't ever do this!
//   SqlCommand cmd = new SqlCommand(
//    "select * from Customers where city = '" + inputCity + "'";

   // 1. declare command object with parameter
   SqlCommand cmd = new SqlCommand(
    "select * from Customers where city = @City", conn);

   // 2. define parameters used in command object
   SqlParameter param  = new SqlParameter();
   param.ParameterName = "@City";
   param.Value         = inputCity;

   // 3. add new parameter to command object
   cmd.Parameters.Add(param);

   // get data stream
   reader = cmd.ExecuteReader();

   // write each record
   while(reader.Read())
   {
    Console.WriteLine("{0}, {1}", 
     reader["CompanyName"], 
     reader["ContactName"]);
   }
  }
  finally
  {
   // close reader
   if (reader != null)
   {
    reader.Close();
   }

   // close connection
   if (conn != null)
   {
    conn.Close();
   }
  }
 }
}
The code in Listing 1 simply retrieves records for each customer that lives in London.  This was made more secure through the use of parameters.  Besides using parameters, all of the other code contains techniques you've learned in previous lessons.

Summary

You should use parameters to filter queries in a secure manner.  The process of using parameter contains three steps:  define the parameter in the SqlCommand command string, declare the SqlParameter object with applicable properties, and assign the SqlParameter object to the SqlCommand object.  When the SqlCommand executes, parameters will be replaced with values specified by the SqlParameter object.

Lesson 05: Working with Disconnected Data - The DataSet and SqlDataAdapter

This lesson explains how to work with disconnected data, using the DataSet and SqlDataAdapter objects.  Here are the objectives of this lesson:
  • Understand the need for disconnected data.
  • Obtain a basic understanding of what a DataSet is for.
  • Learn to use a SqlDataAdapter to retrieve and update data.

Introduction

In Lesson 3, we discussed a fully connected mode of operation for interacting with a data source by using the SqlCommand object.  In Lesson 4, we learned about how to read data quickly an let go of the connection with the SqlDataReader.  This Lesson shows how to accomplish something in-between SqlConnection and SqlDataReader interaction by using the DataSet and SqlDataAdapter objects.
A DataSet is an in-memory data store that can hold numerous tables.  DataSets only hold data and do not interact with a data source.  It is the SqlDataAdapter that manages connections with the data source and gives us disconnected behavior.  The SqlDataAdapter opens a connection only when required and closes it as soon as it has performed its task.  For example, the SqlDataAdapter performs the following tasks when filling a DataSet with data:
  1. Open connection
  2. Retrieve data into DataSet
  3. Close connection
and performs the following actions when updating data source with DataSet changes:
  1. Open connection
  2. Write changes from DataSet to data source
  3. Close connection
In between the Fill and Update operations, data source connections are closed and you are free to read and write data with the DataSet as you need.  These are the mechanics of working with disconnected data.  Because the applications holds on to connections only when necessary, the application becomes more scalable.
A couple scenarios illustrate why you would want to work with disconnected data: people working without network connectivity and making Web sites more scalable.  Consider sales people who need customer data as they travel.  At the beginning of the day, they'll need to sync up with the main database to have the latest information available.  During the day, they'll make modifications to existing customer data, add new customers, and input new orders.  This is okay because they have a given region or customer base where other people won't be changing the same records.  At the end of the day, the sales person will connect to the network and update changes for overnight processing.
Another scenario is making a Web site more scalable.  With a SqlDataReader, you have to go back to the database for records every time you show a page.  This requires a new connection for each page load, which will hurt scalability as the number of users increase.  One way to relieve this is to use a DataSet that is updated one time and stored in cache.  Every request for the page checks the cache and loads the data if it isn't there or just pulls the data out of cache and displays it.  This avoids a trip to the database, making your application more efficient.
Exceptions to the scenario above include situations where you need to update data.  You then have to make a decision, based on the nature of how the data will be used as to your strategy.  Use disconnected data when your information is primarily read only, but consider other alternatives (such as using SqlCommand object for immediate update) when your requirements call for something more dynamic.  Also, if the amount of data is so large that holding it in memory is impractical, you will need to use SqlDataReader for read-only data.  Really, one could come up with all kinds of exceptions, but the true guiding force should be the requirements of your application which will influence what your design should be.

Creating a DataSet Object

There isn't anything special about instantiating a DataSet.  You just create a new instance, just like any other object:
DataSet dsCustomers = new DataSet();
The DataSet constructor doesn't require parameters.  However there is one overload that accepts a string for the name of the DataSet, which is used if you were to serialize the data to XML.  Since that isn't a requirement for this example, I left it out.  Right now, the DataSet is empty and you need a SqlDataAdapter to load it.

Creating A SqlDataAdapter

The SqlDataAdapter holds the SQL commands and connection object for reading and writing data.  You initialize it with a SQL select statement and connection object:
SqlDataAdapter daCustomers = new SqlDataAdapter(
    "select CustomerID, CompanyName from Customers", conn);

The code above creates a new SqlDataAdapter, daCustomers.  The SQL select statement specifies what data will be read into a DataSet.  The connection object, conn, should have already been instantiated, but not opened.  It is the SqlDataAdapter's responsibility to open and close the connection during Fill and Update method calls.
As indicated earlier, the SqlDataAdapter contains all of the commands necessary to interact with the data source.  The code showed how to specify the select statment, but didn't show the insert, update, and delete statements.  These are added to the SqlDataAdapter after it is instantiated.
There are two ways to add insert, update, and delete commands:  via SqlDataAdapter properties or with a SqlCommandBuilder.  In this lesson, I'm going to show you the easy way of doing it with the SqlCommandBuilder.  In a later lesson, I'll show you how to use the SqlDataAdapter properties, which takes more work but will give you more capabilities than what the SqlCommandBuilder does.  Here's how to add commands to the SqlDataAdapter with the SqlCommandBuilder:
SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daCustomers);
Notice in the code above that the SqlCommandBuilder is instantiated with a single constructor parameter of the SqlDataAdapter, daCustomers, instance.  This tells the SqlCommandBuilder what SqlDataAdapter to add commands to.  The SqlCommandBuilder will read the SQL select statement (specified when the SqlDataAdapter was instantiated), infer the insert, update, and delete commands, and assign the new commands to the Insert, Update, and Delete properties of the SqlDataAdapter, respectively.
As I mentioned earlier, the SqlCommandBuilder has limitations.  It works when you do a simple select statement on a single table.  However, when you need a join of two or mor tables or must do a stored procedure, it won't work.  I'll describe a work-around for these scenarios in future lessons.

Filling the DataSet

Once you have a DataSet and SqlDataAdapter instances, you need to fill the DataSet.  Here's how to do it, by using the Fill method of the SqlDataAdapter:
daCustomers.Fill(dsCustomers, "Customers");
The Fill method, in the code above, takes two parameters: a DataSet and a table name.  The DataSet must be instantiated before trying to fill it with data.  The second parameter is the name of the table that will be created in the DataSet.  You can name the table anything you want.  Its purpose is so you can identify the table with a meaningful name later on.  Typically, I'll give it the same name as the database table.  However, if the SqlDataAdapter's select command contains a join, you'll need to find another meaningful name.
The Fill method has an overload that accepts one parameter for the DataSet only.  In that case, the table created has a default name of "table1" for the first table.  The number will be incremented (table2, table3, ..., tableN) for each table added to the DataSet where the table name was not specified in the Fill method.

Using the DataSet

A DataSet will bind with both ASP.NET and Windows forms DataGrids.  Here's an example that assigns the DataSet to a Windows forms DataGrid:
dgCustomers.DataSource = dsCustomers;
dgCustomers.DataMember = "Customers";

The first thing we do, in the code above, is assign the DataSet to the DataSource property of the DataGrid.  This lets the DataGrid know that it has something to bind to, but you will get a '+' sign in the GUI because the DataSet can hold multiple tables and this would allow you to expand each available table.  To specify exactly which table to use, set the DataGrid's DataMember property to the name of the table.  In the example, we set the name to Customers, which is the same name used as the second parameter to the SqlDataAdapter Fill method.  This is why I like to give the table a name in the Fill method, as it makes subsequent code more readable.

Updating Changes

After modifications are made to the data, you'll want to write the changes back to the database.  Refer to previous discussion in the Introduction of this article on update guidance.  The following code shows how to use the Update method of the SqlDataAdapter to push modifications back to the database.
daCustomers.Update(dsCustomers, "Customers");
The Update method, above, is called on the SqlDataAdapter instance that originally filled the dsCustomers DataSet.  The second parameter to the Update method specifies which table, from the DataSet, to update.  The table contains a list of records that have been modified and the Insert, Update, and Delete properties of the SqlDataAdapter contain the SQL statements used to make database modifications.

Putting it All Together

Until now, you've seen the pieces required to implement disconnected data managment.  What you really need is to see all this implemented in an application.  Listing 1 shows how the code from all the previous sections is used in a working program that has been simplified to enhance the points of this lesson:
Listing 1: Implementing a Disconnected Data Management Strategy
using System;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Windows.Forms;

class DisconnectedDataform : Form
{
 private SqlConnection  conn;
 private SqlDataAdapter daCustomers;

 private DataSet  dsCustomers;
 private DataGrid dgCustomers;

 private const string tableName = "Customers";

 // initialize form with DataGrid and Button
 public DisconnectedDataform()
 {
  // fill dataset
  Initdata();

  // set up datagrid
  dgCustomers = new DataGrid();
  dgCustomers.Location = new Point(5, 5);
  dgCustomers.Size = new Size(
   this.ClientRectangle.Size.Width - 10, 
   this.ClientRectangle.Height - 50);
  dgCustomers.DataSource = dsCustomers;
  dgCustomers.DataMember = tableName;

  // create update button
  Button btnUpdate = new Button();
  btnUpdate.Text = "Update";
  btnUpdate.Location = new Point(
   this.ClientRectangle.Width/2 - btnUpdate.Width/2,
   this.ClientRectangle.Height - (btnUpdate.Height + 10));
  btnUpdate.Click += new EventHandler(btnUpdateClicked);

  // make sure controls appear on form
  Controls.AddRange(new Control[] { dgCustomers, btnUpdate });
 }

 // set up ADO.NET objects
 public void Initdata()
 {
  // instantiate the connection
  conn = new SqlConnection(
   "Server=(local);DataBase=Northwind;Integrated Security=SSPI");
  
  // 1. instantiate a new DataSet
  dsCustomers = new DataSet();

  // 2. init SqlDataAdapter with select command and connection
  daCustomers = new SqlDataAdapter(
   "select CustomerID, CompanyName from Customers", conn);

  // 3. fill in insert, update, and delete commands
  SqlCommandBuilder cmdBldr = new SqlCommandBuilder(daCustomers);
  
  // 4. fill the dataset
  daCustomers.Fill(dsCustomers, tableName);
 }

 // Update button was clicked
 public void btnUpdateClicked(object sender, EventArgs e)
 {
  // write changes back to DataBase
  daCustomers.Update(dsCustomers, tableName);
 }

 // start the Windows form
 static void Main()
 {
  Application.Run(new DisconnectedDataForm());
 }
 }
The Initdata method in Listing 1 contains the methods necessary to set up the SqlDataAdapter and DataSet.  Notice that various data objects are defined at class level so they can be used in multiple methods.  The DataGrid's DataSource property is set in the constructor.  Whenever a user clicks the Update button, the Update method in the btnUpdateClicked event handler is called, pushing modifications back to the database.

Summary

DataSets hold multiple tables and can be kept in memory and reused.  The SqlDataAdapter enables you to fill a DataSet and Update changes back to the database.  You don't have to worry about opening and closing the SqlConnection because the SqlDataAdapter does it automatically.  A SqlCommandBuilder populates insert, update, and delete commands based on the SqlDataAdapter's select statement.  Use the Fill method of the SqlDataAdapter to fill a DataSet with data.  Call the SqlDataAdapter's Update method to push changes back to a database.

Lesson 04: Reading Data with the SqlDataReader

This lesson explains how to read data with a SqlDataReader object.  Here are the objectives of this lesson:
  • Learn what a SqlDataReader is used for.
  • Know how to read data using a SqlDataReader.
  • Understand the need to close a SqlDataReader.

Introduction

A SqlDataReader is a type that is good for reading data in the most efficient manner possible.  You can *not* use it for writing data.  SqlDataReaders are often described as fast-forward firehose-like streams of data.
You can read from SqlDataReader objects in a forward-only sequential manner.  Once you've read some data, you must save it because you will not be able to go back and read it again.
The forward only design of the SqlDataReader is what enables it to be fast.  It doesn't have overhead associated with traversing the data or writing it back to the data source.  Therefore, if your only requirement for a group of data is for reading one time and you want the fastest method possible, the SqlDataReader is the best choice.  Also, if the amount of data you need to read is larger than what you would prefer to hold in memory beyond a single call, then the streaming behavior of the SqlDataReader would be a good choice.
Note:  Observe that I used the term "one time" in the previous paragraph when discussing the reasons why you would use a SqlDataReader.  As with anything, there are exceptions.  In many cases, it is more efficient to use a cached DataSet.  While caching is outside the scope of this tutorial, we will discuss using DataSet objects in the next lesson.

Creating a SqlDataReader Object

Getting an instance of a SqlDataReader is a little different than the way you instantiate other ADO.NET objects.  You must call ExecuteReader on a command object, like this:
    SqlDataReader rdr = cmd.ExecuteReader();
The ExecuteReader method of the SqlCommand object, cmd , returns a SqlDataReader instance.  Creating a SqlDataReader with the new operator doesn't do anything for you.  As you learned in previous lessons, the SqlCommand object references the connection and the SQL statement necessary for the SqlDataReader to obtain data.

Reading Data

previous lessons contained code that used a SqlDataReader, but the discussion was delayed so we could focus on the specific subject of that particular lesson.  This lesson builds from what you've seen and explains how to use the SqlDataReader.
As explained earlier, the SqlDataReader returns data via a sequential stream.  To read this data, you must pull data from a table row-by-row.  Once a row has been read, the previous row is no longer available.  To read that row again, you would have to create a new instance of the SqlDataReader and read through the data stream again.
The typical method of reading from the data stream returned by the SqlDataReader is to iterate through each row with a while loop.  The following code shows how to accomplish this:
while (rdr.Read())
 {
  // get the results of each column
  string contact = (string)rdr["ContactName"];
  string company = (string)rdr["CompanyName"];
  string city    = (string)rdr["City"];

  // print out the results
  Console.Write("{0,-25}", contact);
  Console.Write("{0,-20}", city);
  Console.Write("{0,-25}", company);
  Console.WriteLine();
 }
Notice the call to Read on the SqlDataReader, rdr, in the while loop condition in the code above.  The return value of Read is type bool and returns true as long as there are more records to read.  After the last record in the data stream has been read, Read returns false.
In previous lessons, we extracted the first column from the row by using the SqlDataReader indexer, i.e. rdr[0].  You can extract each column of the row with a numeric indexer like this, but it isn't very readable.  The example above uses a string indexer, where the string is the column name from the SQL query (the table column name if you used an asterisk, *.  String indexers are much more readable, making the code easier to maintain.
Regardless of the type of the indexer parameter, a SqlDataReader indexer will return type object.  This is why the example above casts results to a string.  Once the values are extracted, you can do whatever you want with them, such as printing them to output with Console type methods.

Finishing Up

Always remember to close your SqlDataReader, just like you need to close the SqlConnection.  Wrap the data access code in a try block and put the close operation in the finally block, like this:
try
 {
  // data access code
 }
 finally
 {
  // 3. close the reader
  if (rdr != null)
  {
   rdr.Close();
  }

  // close the connection too
 } 
The code above checks the SqlDataReader to make sure it isn't null.  After the code knows that a good instance of the SqlDataReader exists, it can close it.  Listing 1 shows the code for the previous sections in its entirety.
Listing 1: Using the SqlDataReader
using System;
using System.Data;
using System.Data.SqlClient;

namespace Lesson04
{
 class ReaderDemo
 {
  static void Main()
  {
   ReaderDemo rd = new ReaderDemo();
   rd.SimpleRead();
  }

  public void SimpleRead()
  {
   // declare the SqlDataReader, which is used in
   // both the try block and the finally block
   SqlDataReader rdr = null;

   // create a connection object
   SqlConnection conn = new SqlConnection(
"Data Source=(local);Initial Catalog=Northwind;Integrated Security=SSPI");

   // create a command object
   SqlCommand cmd  = new SqlCommand(
    "select * from Customers", conn);

   try
   {
    // open the connection
    conn.Open();

    // 1.  get an instance of the SqlDataReader
    rdr = cmd.ExecuteReader();

    // print a set of column headers
    Console.WriteLine(
"Contact Name             City                Company Name");
    Console.WriteLine(
"------------             ------------        ------------");

    // 2.  print necessary columns of each record
    while (rdr.Read())
    {
     // get the results of each column
     string contact = (string)rdr["ContactName"];
     string company = (string)rdr["CompanyName"];
     string city    = (string)rdr["City"];

     // print out the results
     Console.Write("{0,-25}", contact);
     Console.Write("{0,-20}", city);
     Console.Write("{0,-25}", company);
     Console.WriteLine();
    }
   }
   finally
   {
    // 3. close the reader
    if (rdr != null)
    {
     rdr.Close();
    }

    // close the connection
    if (conn != null)
    {
     conn.Close();
    }
   } 
  }
 }
}

Summary

SqlDataReader objects allow you to read data in a fast forward-only manner.  You obtain data by reading each row from the data stream.  Call the Close method of the SqlDataReader to ensure there are not any resource leaks.