Sunday, December 23, 2012

Accessing list items using the object model


There are various ways of accessing the List Items (SPListItem) in a List (SPList).

Accessing list items in the same site
SPList.Items foreach
This SPListItem Collection works directly against the underlying SharePoint List (SPList). Any updates made against List Items are updated on the server.

The below code shows enumerating through all List Items in a List.

using (SPWeb web = siteCollection.AllWebs["webname"])
{
  SPListItemCollection items = web.Lists["Document Library"].Items;
  foreach (SPListItem item in items)
  {
    Console.Write(item.Title);
  }
}

Iterating on Collection Properties of objects with for loop

Please note that when iterating through a list, to reduce underlying calls to the database, be very careful what property you iterate on. Make sure in this example you do not use:
for(int i; i <= web.Lists["Document Library"].Items.Count; i++)
{
   Console.WriteLine(web.Lists["Document Library"].Items[i].Title.ToString());
}
This will cause a new SPListItemCollection object everytime the property is accessed. An example of the performance hit on this would be that if the list had 100 items, you would get 200 hits to the database. By instantiating an SPListItemCollection object outside of the foreach loop reduces this significantly.

SPListItemCollection items = web.Lists["Document Library"].Items;
for(int i; i <= items.Count; i++)
{
   Console.WriteLine(items[i].Title.ToString());
}
Source: The wrong way to iterate through SharePoint SPList Items by Andreas Grabner

Accessing List Item instances
The below code shows accessing a List Item by its identifier (Int).

using (SPWeb web = siteCollection.AllWebs["webname"])
{
  SPList list = web.Lists["Document Library"];
  SPListItem item = list.GetItemById(id);
  Console.Write(item.Title);
}

Performance mini Case Study
Gopinath Devadasshad an issue with this code pattern using GetItemById and noticed a 30 second to 3 second difference in performance compared to using SPQuery (see below).


The below code shows accessing a List Item by it's unique identifier (Guid).

using (SPWeb web = siteCollection.AllWebs["webname"])
{
  SPList list = web.Lists["Document Library"];
  SPListItem item = list.GetItemByUniqueId(guid);
  Console.Write(item.Title);
}

MSDN Guidance
Please note that it is advised not to use SPList.Items[System.Guid] and SPList.Items[System.Int32] as mentioned in 'Table 1. Alternatives to SPList.Items on the source referenced below'.
Source: MSDN:Best Practices: Common Coding Issues When Using the SharePoint Object Model

SPList.Items foreach with SPQuery
SPList list = SPContext.Current.Web.Lists["Contracts"];
SPQuery query = new SPQuery();
query.Query = string.Format("<Where><Eq><FieldRef Name='ID' /><Value Type='Counter'>{0}</Value></Eq></Where>","407");
SPListItem item = list.GetItems(query)[0];
SPList.Items.GetDataTable()
SPListItemCollection.GetDataTable Method (Microsoft.SharePoint)
Returns a copy of the list items as an ADO.NET DataTable, any updates to the DataTable do not affect the underlying SharePoint List (SPList).

using (SPWeb web = siteCollection.AllWebs["webname"])
{
  SPList list = web.Lists["Document Library"];
  DataTable table = list.GetItems(list.DefaultView).GetDataTable();
  //TODO: enumerate DataTable
}

SPList.Items.GetDataTable() with SPQuery
Returns a copy of the list items as an ADO.NET DataTable, any updates to the DataTable do not affect the underlying SharePoint List (SPList).


PortalSiteMapProvider.GetCachedListItemsByQuery
Requires Microsoft Office SharePoint Server (not WSS) using the Publishing feature. Returns a copy of the list items, any updates to the DataTable do not affect the underlying SharePoint List (SPList).

PortalSiteMapProvider psmp = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;
SPQuery query = new SPQuery
{
  ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' />",
  Query = "",  // replace with your CAML query
  RowLimit = 10
};
SPListItemCollection listItemNodes = _portalSiteMapProvider.GetCachedListItemsByQuery(
((PortalSiteMapNode)psmp.CurrentNode).WebNode,
   "List Title", query, web);

SPWeb.GetListItem(string url)
The SPWeb.GetListItem method  allows you to retrieve a list item using its URL:

SPListItem listItem = SPContext.Current.Web.GetListItem(listItemUrl);
Such approach for retrieving list items is extremely useful while working with Publishing Pages with elevated privileges:

SPSecurity.RunWithElevatedPrivileges(delegate() {
  using (SPSite site = new SPSite(SPContext.Current.Site.ID))
  {
    using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
    {
      string listItemUrl = SPContext.Current.ListItemServerRelativeUrl;
      SPListItem listItem = web.GetListItem(listItemUrl);
      // do something with the list item
    }
  }
});

Keep in mind
In spite of being called in the context of a site (web.GetListItem) the GetListItem(string) method requires a server-relative URL in order to retrieve a list item. Providing a site-relative URL will result in a COMException (more information available @ http://blog.mastykarz.nl/inconvenient-spweb-getlistitem-exception-hresult-0x80070001/

List Web Service
See Lists SharePoint Web Service

Accessing list items in multiple sites
Waldek Mastykarz: Performance of content aggregation queries on multiple lists

SPSiteDataQuery
Returns a copy of the list items, any updates to the DataTable do not affect the underlying SharePoint List (SPList).

Source: Chakkaradeep Chandran

StringBuilder queryBuilder = new StringBuilder();
SPSiteDataQuery oQuery = new SPSiteDataQuery();
oQuery.Lists = "<Lists BaseType='1'/>";
oQuery.RowLimit = 100;
oQuery.Webs = "<Webs Scope=\"Recursive\" />";

queryBuilder.Append("<Where><Eq><FieldRef Name=\"UniqueId\" />");
queryBuilder.Append("<Value Type=\"Lookup\">");
queryBuilder.Append("e5d483ac-1c4a-4699-bcd1-dd0bb0455a71");
queryBuilder.Append("</Value></Eq></Where>");

oQuery.Query = queryBuilder.ToString();

DataTable dtResult = web.GetSiteData(oQuery);


More on SPSiteDataQuery
SPSiteDataQuery Samples for WSS v3.0

CrossListQueryCache
Uses the same caching functionality as the Content Query Web Part and similarly requires Microsoft Office SharePoint Server 2007 Standard minimum. Returns a copy of the list items, any updates to the DataTable do not affect the underlying SharePoint List (SPList).

CrossListQueryInfo clqInfo = new CrossListQueryInfo();
clqInfo.Webs = "<Webs Scope='SiteCollection'/>";
clqInfo.Lists = "<Lists ServerTemplate='101'/>";
clqInfo.ViewFields = "<FieldRef Name='Title' /><FieldRef Name='ID' />";
clqInfo.Query = ""; // replace with your CAML query
clqInfo.RowLimit = 10;
clqInfo.UseCache = true;

CrossListQueryCache clqCache = new CrossListQueryCache(clqInfo);
DataTable resultsTable = clqCache.GetSiteData(SPContext.Current.Site);

Query context
David Crabbe explains that only the current site collection can be queried using CrossListQueryCache.

Caching
Jeff Dalton has found that only GetSiteData methods using SPSite parameters are cached (not SPWeb).

MSDN references
CrossListQueryInfo
CrossListQueryCache

Search
Returns a copy of the list items, any updates to the DataTable do not affect the underlying SharePoint List (SPList).


External Links
White Paper: Working with large lists in Office SharePoint® Server 2007 - Extremely good white paper showing the differences in performance of various methods of accessing lists with graphs to prove it!
Measure 48,000 times; Cut once by Scott Singleton Great post on performance based on method used to access List Items.



Original Post by: Jeremy Thake

Monday, November 19, 2012

Convert column data type from multiline to single line in SharePoint 2010


If you create a SharePoint list by importing a spreadsheet you will find that in SharePoint 2010 all free text columns are converted to the multiline data type by default.

This is a problem if you want to filter the multiline columns in a list by clicking on the column heading because column filtering will only work if the column is a single line data type.

So to change a multiline data type column to a single line do this:

1.  Browse to the "List Settings" for the list.

2. Click on the multiline column:


3. Change the Rich Text property to Plain text and press OK. Press OK again when warned:

4. Select the same column again as in step 2.

5. You should now see an option to change the data type to Single line of text. Press OK when done and press OK to the warning:



You can also do this in SharePoint 2010 Designer but you must first change the Rich text setting to Plain text and save the changes, then change from multiline to single line, click off the column, OK the warning then save again.

Thursday, November 8, 2012

How to get database records for last 7 days date or last week only


To get the records for the last 7 days, it would be something like:

select RecordDate, Id
from your_table

where RecordDate > DATEADD(day, -7, GETDATE())

To get the records for the last week only (within the last week not last 7 days)


select RecordDate, Id
from your_table

where RecordDate > DATEADD(day, -7, GETDATE())
and DATEPART(week, RecordDate) = DATEPART(week, GETDATE())


This query will return all records having a date later than 7 days before current date/time.

If you don't want the hours to be taken into account, then try something like this (works only on 2008 due to date datatype cast):

select RecordDate, Id
from your_table
where RecordDate > DATEADD(day, -7, cast(GETDATE() as date))
and DATEPART(week, RecordDate) = DATEPART(week, GETDATE())

Here's the version without the hours for 2005:

select RecordDate, Id
    from your_table
    where RecordDate > DATEADD(day, -7, CONVERT(datetime, CONVERT(char(10), GETDATE(), 
101)))
and DATEPART(week, RecordDate) = DATEPART(week, GETDATE())



That's it :)

Sunday, November 4, 2012

Column and View Permissions in SharePoint 2010


Recently I ran into a codeplex webpart that allows you to specificy column and view permissions for SharePoint 2010.

View permissions disable access to some views on a SharePoint Library or list, and the column permissions hide or set columns to ReadOnly for specified groups. Column permissions work on normal list views, where authenticated users will see columns. Column permissions also apply on the three default SharePoint aspx pages:

EditForm.aspx
NewForm.aspx
DisplayForm.aspx

This feature can be downloaded from http://spcolumnpermission.codeplex.com/

Install instructions and a more in depth description is given on the site. Below is a screenshot from list settings page where the view and the column permission for a list/library can be set up/configured



This Solution is only for SharePoint 2010!

Features:
Column Permission

- Hide or Read Only Columns in a List Forms (New/Edit/Display)
- Hide Columns in Views
- Hide Columns in Alert Me Emails
- Specify the permission for Users, SharePoint Groups or Active Directory Groups
View Permission
- Disable Views
- Hide Views in Context Menus
- Automatically Disable Views in Custom WebPart Zones
- Specify the permission for Users, SharePoint Groups or Active Directory Groups

Column Permission:
1. After successful Installation and Activation on Site Collection you will see two new links in your List/Document Library Settings page.


Wednesday, October 3, 2012

Top 10 SEO tips for bloggers


From years of experience in operating mainly WordPress-based blogs, I have learned valuable lessons on how to optimize blogs for search engines and increase traffic to the sites. Here are my Top 10 SEO tips for bloggers; I hope these insightful tips can help improve your blog’s SEO.

1. Conduct proper keyword research and use keywords in your title and content. The title in your home page is the most important place to feature your most important keywords. When you post new articles, keep in mind that most blog platforms will make your article title the HTML title tag as well. Therefore, create your titles with keywords you want to target.

2. Be familiar with your blogging platform to use built-in SEO features. Install additional SEO pluggins. For WordPress, "All in One SEO" or "Platinum SEO" is recommended. They offer many settings that help to create a more SEO-friendly site.

3. Use SEO-friendly URLs. Basically adding keywords in your URLs is a good idea. In WordPress, this is done by turning on a function called "Permalinks."

4. Write original content. Do not copy content from other sites, and if you do, make sure to rewrite it completely to make it your own. More often than not, duplicate content gets filtered by the search engines.

5. Write blog posts on a regular basis and cover the latest topics and trends, which tend to get more traffic while they are hot. Fresh content is part of Google's algorithm.

6. Optimize your image names and alt tags to include keywords for better placement in the image search portion of the search engines.

7. Publish links to your posts on social media sites like Facebook, Twitter and LinkedIn. Also, submit them to social bookmarking sites such as StumbleUpon and Reddit. Social media involvement and links are good for SEO purposes.

8. Build links to your main page and internal posts. If you own several blogs, try to find similar posts and link them to each other.

9. Write guest blog posts on similar sites for link building purposes. A good way to do this is to ask other bloggers to exchange articles, with guest blog credits. You can also participate in link exchange with other bloggers from blogrolls, but in general try to not have too many outgoing links from your own blogroll, as it may reduce the value of your website.

10. Go easy on importing RSS feeds into your blog. While it could be a good source for additional content, you want the majority of your content to be original. If you’re going to use RSS feeds, I recommend keeping it to less than 10 percent of your overall content. If your regular content does not keep up with that ratio, then remove old RSS posts regularly. There was a time when the "Autobloged" plugin for WordPress was being used by many bloggers, or I should say spammy bloggers, with great success. Sites would receive a massive amount of content in little time and would end up getting hundreds of rankings. However, the Panda update makes this difficult.

While there are many more tips I can share with you, the ones I mentioned are my top ten. I hope you enjoyed the article and that the tips can help you to improve your rankings.

Sunday, July 22, 2012

Remove Format when copy paste in rich text editor in SharePoint 2010


How to avoid the formatting that comes along when you copy paste content from a site or word document to the Rich Text Editor (RTE) field in sharepoint? Ofcourse RTE already have an option Clear Formatting that can be used to clear after pasting the content,, but I do not want the format to be copied at first.

So after digging into SP.UI.RTE.js I have come up with a small script that will not paste the markup but only text.


    //Disable the RTE paste option. Restricts to "Paste Plain Text"
    function disableMarkupPasteForRTE()
    {
     Type.registerNamespace("RTE");
     if (RTE)
     {
      if(RTE.RichTextEditor != null)
      {
       RTE.RichTextEditor.paste = function() { RTE.Cursor.paste(true); }
       // Handle Ctrl+V short cut options in rich text editor
       RTE.Cursor.$3C_0 = true;
      }
     }
    }

I used the below standard sharepoint javascript function that will run the above or any javascript function on load of page.

    _spBodyOnLoadFunctionNames.push("disableMarkupPasteForRTE");

The final script will look like this:



<asp:Content ContentPlaceHolderId="PlaceHolderBodyAreaClass" runat="server">
<script type="text/javascript" id="disableMarkupPasteForRTE">
//Disable the RTE paste option. Restricts to "Paste Plain Text" 
    function disableMarkupPasteForRTE()
    {
     Type.registerNamespace("RTE");
     if (RTE)
     {
      if(RTE.RichTextEditor != null)
      {
       RTE.RichTextEditor.paste = function() { RTE.Cursor.paste(true); }
       // Handle Ctrl+V short cut options in rich text editor
       RTE.Cursor.$3C_0 = true;
      }
     }
    }
     _spBodyOnLoadFunctionNames.push("disableMarkupPasteForRTE");
    </script>
</asp:Content>




Wednesday, June 6, 2012

Four Critical Web Design Rules


"Content is King! If you want a website to generate back-links and have quality content the search engines love, be sure to make it readable by both people and search engines. Search engines are working to give people quality results. Thus, they are looking for sites with quality content. So - by building site content for people, not only are you getting back to basics (information dissemination to people via the Internet), you are creating a site search engines will love. So, build sites for people - and the search engines will come.

When creating a new website or redesigning an existing site, there are four critical rules which should be followed to make the site effective, functional, loved by search engines - and successful.

1. Easy to Read

When building a website, the first thing you need to be sure of is that your website is easy to read. When you write content, remember that most web site visitors don't read every word of a page - in fact, they only scan pages to find what they want.

Break up Your Content

Break up your pages and use headers between major ideas so people scanning your site can find what they want quickly. Use meaningful headers between each paragraph or major idea - this helps with SEO. Headers should be created with the H1 through H4 tags for SEO. Always use good writing structure. Additionally, avoid long paragraphs that run on. You should break up any long paragraphs.

Color and Fonts

To help readability, use high contrast colors between font and background. Black text against a white background may seem stark, but it is very readable. To make a website easy on the eyes, try an off-white background and a dark gray (almost black) text color.

Things to avoid with content color: 
  • Avoid vibrant background colors like purple or yellow. Such back colors make text difficult to read.

  • Avoid using an image behind your text.

  • Avoid using bright text colors on bright backgrounds.

Fonts Matter

One simple statement covers the font issue: 

Simple fonts are the best; the more fancy the font, the harder it is to read. 

Since many browsers only have the standard font set, use standard fonts. In reality, there is no "standard", but there are certain fonts that are installed on most browsers. These include Arial, Verdana, Tahoma and Times New Roman. Your readers will see something different than you see if you use other fonts. 

Standard Compliant Browser for Development

When developing and testing your site, use a Standards compliant browser like FireFox. If you develop your site to be standards compliant, it will work in most browsers, including MS Internet Explorer (IE). It is recommended that you test your site using the latest and last browser versions of IE (IE6 and IE7). To run multiple versions of IE on the same machine, TredoSoft.com has a free installer that will install multiple versions of IE. It works great! 

Keywords in Content

Of course, when writing content, not only should it be formatted to be readable, but it must also be consumable by not only people, but by search engines. One way to make the subject of the content known to search engines is to use the keywords that people use to search for your site in your content. Be sure to use keywords in your header tags, your first paragraph and throughout your text. The keyword density should be between 4% and 7% - but any more than that could 1) be hard to read and still make sense and 2) be considered spam by search engines and banned. Keywords should also be used in your TITLE tags and your Meta description. 

2. Simplify Navigation

The menus and links make up the navigation that the visitor uses to get from page to page in a site. Always plan a site around how people will get from page to page. A visitor to your site should be able to get to what they want within three clicks of their mouse. 

Multiple navigation points makes it easy to find things. Repeat the top menu and at the bottom. Also create a left or right menu. 

Using links within your text to other areas on your site. You can create links so that they are good for search engine optimization (SEO). There are generally two ways to create links within your text: 

  1. The wrong way: "For search engine optimization techniques, click here."

  2. The right way: "Good techniques for search engine optimization are important to use."

Using link text (anchor text) that describes what the link is about is the best way. Search engine web crawlers (programs that automatically index the contents of websites) visit your site, they "read" links. Spiders can index descriptive links into a subject or keyword category. Spiders have nothing to work with when reading a "click here" until it reaches the linked page. 

This is Cross Linking - use it as much as possible when it makes sense to do so when writing your content. 

3. Consistent Design

At most, one or two layouts should be used in your site design. As a reader browses your site, they should be able to get used to looking in the same place for your navigation, for your sub-navigation and for your content. That's all there is to say about that. 

4. Lower Page Weight is Better

Page weight is the total size of a page on your site in bytes - code, text and images. Your site's page weight makes a big difference to your viewers. Lighter page weight is better for your readers because the page will download faster. The faster a page downloads, the faster they will get to the content. 

What is Means to be Light

  • No large images.

  • Fewer images are better.

  • Optimize images for the web at no more than 72 dpi

  • Use as small an image dimension as possible for the given design.

  • Use a table td bgcolor attribute or a background-color style attribute for solid color backgrounds.

  • Make gradients horizontal or vertical (not diagonal) so that you can use a small image "strip" and repeat it.

How "Heavy" Should a Web Page be? 

Certain studies show that 64K is a good maximum webpage size. 64K is a maximum, however it is still, in my opinion, really big! The smaller the page, the better. 25K is good, 15K is even better. There is a balance between design and function. It is a good idea to focus more on function. 

Try putting pages on your web host server as you build your site so you can test it as you go. For pages online, you can test the page weight at www.quasarcr.com/pageweight/ to be sure you are on track. 

Ways to make pages lighter: 

  • Use linked style sheets

  • Use DIVs instead of TABLEs where possible

  • Use simple repeating backgrounds for effect

Summary

Visitors to your website should be able to find what they are looking for within about three clicks. Search engines should be able to navigate easily through your site. Making a site easy to read with consistent page design, and easy to navigate will make it easy to find information. When people can find information, they are more likely to refer your site or link to it - which is exactly what you want to encourage. You will be on the way to building a readable and hopefully successful website that is loved by search engines if you follow these principals.

Accepting Credit Cards on Your Website


Are you thinking of selling things on the web? If so, you will probably also be considering some way in which you can accept credit cards on your site. Since new webmasters who visit thesitewizard.com often ask me about how they can get started accepting payments in this form, this article provides some basic information on adding credit card payment facilities to your website.
(Note: if you do not already have a website, you may also want to read How to Create / Make a Website: The Beginner's A-Z Guide.)

Why Do It?

Credit card payments allow you to take advantage of the following types of customers:
  1. Impulse buyers

    After reading your advertisements and hype on your site, buyers would be all fired up about your product. If they have a means of making a purchase immediately, you've secured that sale. If you only allow cheque payments, the additional time it takes for them to get their cheque book and mail out the cheque may be a deterrence. They may also have second thoughts later.
  2. International customers

    Credit card payment is a tremendous convenience if your customers are overseas. It automatically takes care of the problems of currency differences as well as the time it takes for a cheque to travel to the vendor. You will lose a large number of overseas customers if cheque payment is the only way you can accept payment.

Methods of Accepting Credit Card Payments

There are actually two ways in which you can accept credit cards on your site.
  1. Using Your Own Merchant Account

    To do this, you will need a bank that will allow you to open a merchant account. Requirements for this will vary from country to country, and you should check with your local banks for more information on this.
  2. Through a Third Party Merchant

    There are numerous companies around that are willing to accept credit cards payments on your behalf in exchange for various fees and percentages. These are also known as "payment gateways".

Which Method Should You Use?

The initial costs of opening your own merchant account is usually higher than when you use a third party merchant. Indeed, some third party merchants have no setup fee at all.
However, the transaction fee (which is what you pay the bank or third party merchant for each sale) is much higher when you use a third party as compared to when using your own merchant account.
A third party merchant is usually convenient to use when you don't know if you can actually make much out of your product or service. If you just want to test the water to see how things are, this is usually a good way to start. It is also convenient in that the merchant takes care of everything for you. You just get a cheque at the end of each payment period (if you have earned enough) and concentrate on your products, services and customers. Another benefit is that if you use a reputable third party merchant, your visitors may be more willing to buy your goods online since they trust that merchant to keep their credit card numbers safe.
Having your own merchant account lowers your transaction costs. However, you have to be careful to minimize your credit card risks since you'll be processing the credit card payments yourself. This is not to say that there are no risks attendant in using a third party merchant.

Some Third Party Merchants / Payment Gateways

Here's a list of some third party merchants that you might want to consider if you're looking for ways to accept credit card payments. Except for PayPal, I have not actually tried any of them myself (as a vendor). Check them out carefully and use them at your own risk.
Note that rates and stuff that I publish below were correct at the time I investigated these vendors. It will most likely have changed by the time you read this since the merchants tend to modify their rates from time to time according to market conditions. Make sure that you check the current (up-to-date) details from their site before making any decision.
The list is arranged alphabetically.
CCBill: There are no setup fees. Transaction fees vary (I can't find the schedule though) depending on the volume of sales in each accounting period. According to their website, "these fees are never more than 13.5% of revenues charged during this one-week period for CWIE hosting clients and 14.5% for non-hosting clients".
CCNow: This is only for people who ship tangible, physical products. There is no setup fee, and they charge 9% per transaction except in the November and December where the fees are 8% per transaction (yes, lower).
Google Checkout: Google has its own payment gateway that is available for US and UK sellers. It is mainly for use if you are selling tangible and digital goods, although you can also use it to charge for services and subscriptions. Charges range from 1.9% + $0.30 USD to 2.9% + $0.30 USD per transaction, depending on the volume of sales in the previous month. If your buyer is not from your country (ie, not in the US if you are in the US, or not in the UK if you are in the UK), there is also another 1% processing fee.
Kagi: Kagi's fees seem to vary according to the order size, type of item sold and the type of payment (credit card, cash, money order) used by your customer.
PayPal: This well-known service allows you to set up a Premier or Business account (you are subject to certain limits when receiving credit card payments if you use a Personal account, and probably also higher fees per transaction). The charges range between 1.9% + $0.30 USD to 2.9% + $0.30 USD for each transaction if you are in the US. Non-US users are charged different amounts according to the country. From experience, I find this service easy and fast to setup.
ProPay: A new competitor to PayPal (see elsewhere on this page) that currently only caters to US residents. Depending on the type of account you sign up for, you have to pay an annual fee (starting from $34.95) as well as transaction fees of 3.5% + $0.35 USD. However, to accept cards like American Express and Discover, you have to use their more expensive plans.
RegNow: Designed for software authors to sell their ware, this merchant charges a one-time activation fee of $19.95 USD plus a transaction fee of 6.9% plus $1 USD per unit for their commission (minimum $2 USD charge). They also provide you with facilities that allows you to easily set up an affiliate program.

How to Put an Order Form or Shopping Cart on Your Website

Once you have signed up the vendor of your choice, you will be able to put an order form or shopping cart on your site. Each vendor has a different method for this, but most, if not all, will provide you with premade forms that you can customize for your product or service.
(Note: if you use PayPal, and don't know where to start, see my tutorial How to Put an Order Form or Buy Now Button on Your Website Using PayPal for a step-by-step guide.)

Trying It Out

Whichever you choose, if you are selling things on the Internet, you really have not much choice but to accept credit cards. You probably don't know what you missed until you try it out.
All the best for your business!

This article can be found at http://www.thesitewizard.com/archive/creditcards.shtml

Where are the Documents or files we uploaded or attached stored in SharePoint?


Many of them know, those files are stored under SharePoint Content Database. But on which database table, on which format?
For that, i did a quick research on that, and here i give those results,
  • The AllDocStreams table in SharePoint Content Database stores the Document Contents.
  • The Contents of the document are stored in Content Column in the AllDocStream table.
  • The Content column is the Image Datatype, (stores in the format of Binary).
I provide a simple SQL Query to retrieve the Document List Name,File Name, URL, and the Content (Binary Format)
SELECT AllLists.tp_Title AS ‘List Name’,
AllDocs.LeafName AS ‘File Name’,
AllDocs.DirName AS ‘URL’,
AllDocStreams.Content AS ‘Document Contnt (Binary)’ 
FROM AllDocs 
JOIN AllDocStreams 
ON 
AllDocs.Id=AllDocStreams.Id 
JOIN AllLists 
ON
AllLists.tp_id = AllDocs.ListId

Tuesday, June 5, 2012

How to Choose a Web Host


by Christopher Heng, thesitewizard.com


What are some of the things you should look for when choosing a web host? The criteria for choosing a free web host and a commercial web hosting solution are slightly different although they do overlap. Since thesitewizard.com caters to people who might be looking for either of these types of hosting, I will deal with each of these in turn. If you are only interested in one of these types, you can simply skip to the appropriate section. I have written these sections to be as independant of the other as possible.

Choosing a Free Web Host

  1. Advertising

    Most free web hosts impose advertising on your website. This is done to cover the costs of providing your site the free web space and associated services. Some hosts require you to place a banner on your pages, others display a window that pops up everytime a page on your site loads, while still others impose an advertising frame on your site. There is really no hard and fast rule which is to be preferred: some people hate a pop-up window, other webmasters dislike having to stuff banner codes onto their pages, and many people cannot stand an advertising frame (which may cause problems when you submit your website to search engines). Whichever method is used, check that you're comfortable with the method.
    Note that free web hosts without forced advertisements aren't necessarily good news. Without a viable means to recover the costs of running their server, such hosts close with alarming frequency.
  2. Amount of web space

    Does it have enough space for your needs? If you envisage that you will expand your site eventually, you might want to anticipate future expansion. Most sites use less than 5MB of web space. Indeed, at one time, one of my other web sites, thefreecountry.com, used less than 5MB of space although it had about 150 pages on the site. Your needs will vary, depending on how many pictures your pages use, whether you need sound files, video clips, etc.
  3. FTP access

    FTP is the most common method used by people to transfer their web pages and other files from their computer to their web host's computer, so that it can be viewed by anyone in the world.
    Some free hosting providers only allow you to design your page with their online site builder. While this is useful for beginners, do you have the option to expand later when you become experienced and their online page builder does not have the facility you need? Online site builders also have significant disadvantages, a subject which I discuss at length in my article comparing online site builders with standalone web editors.
    FTP access, or at the very least, the ability to upload your pages by email or browser, is needed. Personally, I feel FTP access is mandatory, except for the most trivial site.
  4. File type and size limitations

    Watch out for these. Some free hosts impose a maximum size on each of the files you upload (including one with a low of 200KB). Other sites restrict the file types you can upload to HTML and GIF/JPG files. If your needs are different, eg, if you want to distribute your own programs on your pages, you will have to look elsewhere.
  5. Reliability and speed of access

    This is extremely important. A site that is frequently down will lose a lot of visitors. If someone finds your site on the search engine, and he tries to access it but find that it is down, he'll simply go down the list to find another site. Slow access is also very frustrating for visitors (and for you too, when you upload your site). How do you know if a host is reliable or fast? If you can't get feedback from anyone, one way is to try it out yourself over a period of time, both during peak as well as non-peak hours. After all, it is free, so you can always experiment with it.
  6. PHP and/or Perl

    (In case you're wondering: What is PHP and Perl?)
    It's quite possible for a website to work even without PHP or Perl access. For example, you can always use one of the many free script hosting services available that provide counterssearch enginesformspollsmailing lists, etc, without requiring you to dabble with Perl or PHP scripts.
    However if you really want to do it yourself, with the minimum of advertising banners from these free providers, you will need either PHP or Perl access. Note that it is not enough to know they provide PHP or Perl access: you need to know the kind of environment your scripts run under: is it so restrictive that they are of no earthly use? For PHP scripts, does your web host allow you to use the mail() function, which allows your scripts to send email? For Perl scripts, do you have access to sendmail or its workalike?
  7. Bandwidth allotment

    Nowadays, many free web hosts impose a limit on the amount of traffic your website can use per day and per month. This means that if the pages (and graphic images) on your site is loaded by visitors beyond a certain number of times per day (or per month), the web host will disable your web site (or perhaps send you a bill). It is difficult to recommend a specific minimum amount of bandwidth, since it depends on how you design your site, your target audience, and the number of visitors you're able to attract to your site. In general, 100MB traffic per month is too little for anything other than your personal home page and 1-3GB traffic per month is usually adequate for a simple site just starting out. Your mileage, however, will vary.

Choosing a Commercial Web Host

  1. Reliability and speed of access

    Not only should the web host be reliable and fast, it should guarantee its uptime (the time when it is functional). Look for a minimum uptime of 99%. In fact, even 99% is actually too low — it really should be 99.5% or higher. The host should provide some sort of refund (eg prorated refund or discount) if it falls below that figure. Note though that guarantees are often hard to enforce from your end — especially if the host denies there was any downtime. However, without that guarantee, the web host will have little incentive to ensure that its servers are running all the time.
  2. Data Transfer (Traffic/Bandwidth)

    Data transfer (sometimes loosely referred to as "traffic" or "bandwidth") is the amount of bytes transferred from your site to visitors when they browse your site.
    Don't believe any commercial web host that advertises "unlimited bandwidth". The host has to pay for the bandwidth, and if you consume a lot of it, they will not silently bear your costs. Many high bandwidth websites have found this out the hard way when they suddenly receive an exorbitant bill for having "exceeded" the "unlimited bandwidth". Always look for details on how much traffic the package allows. I personally always stay clear of any host that advertises "unlimited transfer", even if the exact amount is specified somewhere else (sometimes buried in their policy statements). Usually you will find that they redefine "unlimited" to be limited in some way.
    In addition, while bandwidth provided is something you should always check, do not be unduly swayed by promises of incredibly huge amounts of bandwidth. Chances are that your website will never be able to use that amount because it will hit other limits, namely resource limits. For more details, see the article The Fine Print in Web Hosting: Resource Usage Limits.
    To give you a rough idea of the typical traffic requirements of a website, most new sites that are not software archives or provide video or music on their site use less than 3 GB of bandwidth per month. Your traffic requirements will grow over time, as your site becomes more well-known (and well-linked), so you will need to also check their policy when you exceed your data transfer limit: is there a published charge per GB over the allowed bandwidth? Is the charge made according to actual usage or are you expected to pre-pay for a potential overage? It is better not to go for hosts that expect you to prepay for overages, since it is very hard to forsee when your site will exceed its bandwidth and by how much.
  3. Disk space

    For the same reason as bandwidth, watch out also for those "unlimited disk space" schemes. Many new sites (that don't host videos or music) need less than 20 MB of web space, so even if you are provided with a host that tempts you with 100 GB (or "unlimited space"), be aware that you are unlikely to use that space, so don't let the 100 GB space be too big a factor in your consideration when comparing with other web hosts. The hosting company is also aware of that, which is why they feel free to offer you that as a means of enticing you to host there. As a rough gauge, thefreecountry.com, which had about 150 pages when this article was first written, used less than 5 MB for its pages and associated files.
  4. Technical support

    Does its technical support function 24 hours a day, 7 days a week (often abbreviated 24/7), all year around? Note that I will not accept a host which does not have staff working on weekends or public holidays. You will be surprised at how often things go wrong at the most inconvenient of times. Incidentally, just because a host advertises that it has 24/7 support does not necessarily mean that it really has that kind of support. Test them out by emailing at midnight and on Saturday nights, Sunday mornings, etc. Check out how long they take to respond. Besides speed of responses, check to see if they are technically competent. You wouldn't want to sign up for a host that is run by a bunch of salesmen who only know how to sell and not fix problems.
  5. FTP, PHP, Perl, SSI, .htaccess, telnet, SSH, MySQL, crontabs

    If you are paying for a site, you really should make sure you have all of these.
    Note that some commercial hosts do not allow you to install PHP or Perl scripts ("What is PHP and Perl?") without their approval. This is not desirable since it means that you have to wait for them before you can implement a feature on your site. ".htaccess" is needed if you are to do things like customize your error pages (pages that display when, say, a user requests for a non-existent page on your site) or to protect your site in various ways (such as to prevent bandwidth theft and hotlinking, etc).
    Telnet or SSH access is useful for certain things, including testing certain scripts (programs), maintaining databases, etc. MySQL ("What is MySQL?") is needed if you want to run a blog or a content management systemCron is a type of program scheduler that lets you run programs at certain times of the day (eg, once a day). Check to see if these facilities are provided.
  6. SSL (secure server), Shopping Cart

    If you are planning on doing any sort of business through your website, you might want to look out to see if the host provides these facilities. These facilities normally involve a higher priced package or additional charges. The main thing is to check to see if they are available at all before you commit to the host. You will definitely need SSL if you want to collect credit card payments on your site.
  7. Email, Autoresponders, POP3, Mail Forwarding

    If you have your own site, you would probably want to have email addresses at your own domain, like sales@yourdomain.com, etc. Does the host provide this with the package? Does it allow you to have a catch-all email account that causes any email address at your domain to be routed to you? Can you set an email address to automatically reply to the sender with a preset message (called an autoresponder)? Can you retrieve your mail with your email software? Can it be automatically forwarded to your current email address?
  8. Control Panel

    This is called various names by different hosts, but essentially, they all allow you to manage different aspects of your web account yourself. Typically, and at the very minimum, it should allow you to do things like add, delete, and manage your email addresses, and change passwords for your account. I would not go for a host where I have to go through their technical support each time I want to change a password or add/delete an email account. Such chores are common maintenance chores that every webmaster performs time and time again, and it would be a great hassle if you had to wait for their technical support to make the changes for you.
  9. Multiple Domain Hosting and Subdomains

    For those who are thinking of selling web space or having multiple domains or subdomains hosted in your account, you should look to see if they provide this, and the amount extra that they charge for this (whether it is a one-time or monthly charge, etc).
  10. Server

    Is the type of operating system and server important? Whether you think so or not on the theoretical level, there are a few practical reasons for looking out for the type of server.
    In general, if you want to use things like write/use ASP programs, you have no choice but to look for a Windows server.
    Otherwise my preference is to sign up for accounts using the often cheaper, more stable and feature-laden Unix systems running the Apache server. In fact, if dynamically generated pages that can access databases (etc) is what you want, you can always use the more portable (and popular) PHP instead of tying yourself down to ASP. Another reason to prefer Unix-based web hosts (which include web hosts using systems like Linux, FreeBSD, OpenBSD, Solaris, etc) using the Apache web server is that these servers allow you to configure a lot of facilities that you typically need on your site (error pages, protecting your images, blocking email harvesters, blocking IP addresses, etc) without having to ask your web host to implement them. Knowledge about configuring Apache servers is also widely available, and can be found on thesitewizard.com's Configuring Apache and .htaccess pages as well.
    For those interested, you can read another discussion on the matter in the "Should You Choose a Linux or a Windows Web Hosting Package? Is There Such a Thing as a Mac Web Host?" article.
  11. Price

    I was actually hesitant to list this, but I guess it's futile not to. However, I would caution that while price is always a factor, you should realise ("realize" in US English) that you often get what you pay for, although it's not necessarily true that the most expensive hosts are the best.
  12. Monthly/Quarterly/Annual Payment Plans

    Most web hosts allow you to select an annual payment plan that gives you a cheaper rate than if you were to pay monthly. My current personal preference is to pay monthly with all new web hosts until I'm assured of their reliability and honesty. Paying monthly allows me to switch web hosts quickly when I find that the current host does not meet my requirements: this way, I'm not tied down to a bad web host because I have prepaid for an entire year. I do this even if the new web host guarantees that they will refund the balance if I'm dissatisfied, since at the point I sign up, I have no assurance that they will honour their guarantee. Later (usually after a couple of years), when I'm satisfied with the host, I may change payment plans to the discounted annual plans.
  13. Resellers?

    Not all hosting companies own or lease their own web servers. Some of them are actually resellers for some other hosting company. The disadvantage of using a reseller is the possibility that you are dealing with people who don't know much about the system they are selling and who take longer to help you (they have to transmit your technical support request to the actual hosting company for it to be acted upon). However, this also depends on both the reseller and the underlying hosting company. It is thus wise not to rule out all resellers; there are a number of reliable and fast ones who are actually quite good and cheap. In fact, a number of resellers sell the same packages cheaper than their original hosting company. If you find out that a particular company is a reseller, you will need to investigate both the reseller and the real hosting company.
  14. International

    If you don't stay in the USA, you have the option of hosting your site with some local provider. The advantage here is the ease of dealing with them (they are after all easily accessible by phone call or a visit), your familiarity with the local laws and easy recourse to those laws should it be necessary. It should be your choice if your target audience is local (eg a local fast food delivery service). On the other hand, hosting it in USA has the advantage of faster access for what is probably the largest number of your overseas visitors (particularly if you have an English-speaking audience). You also have a large number of hosting companies to choose from, and as a result, cheaper prices too.
  15. Others' Reviews

    You should make it a point to check out what others have to say about the web host. Some of the places you can do this include:
    • The newsgroup news:alt.www.webmaster. As you should always do when reading reviews (of anything), read the reviews posted here with a pinch of salt. Some glowing reviews may come from people working for the web host itself, disguised as multiple satisfied customers. Likewise, negative reviews of a particular host can sometimes come from unscrupulous competitors of that host.
    • thesitewizard.com's review, "Which Web Host Would You Recommend? (FAQ)", found at http://www.thesitewizard.com/archive/webhosting.shtml
    • Although not often, I sometimes make comments about a particular web host in my Budget Web Hosts page on thefreecountry.com as well.
    Don't skip this step, or you might find yourself being suckered by a host that everyone else is steering clear of.

The Myth of the Perfect Commercial Host

In general, I doubt that there are any "perfect" web hosting companies around. Note that even if you are prepared to pay a huge price for your hosting needs, it does not guarantee that your host is any good. This is an interesting industry where a high price does not necessarily yield quality hosting and support.
On the other hand, one thing you can probably be sure of is that you will not get top-notched support if you only pay (say) $5 a month. At that price, which company can afford to hire enough good help to cater to all its users?
Like me, you'll probably end up settling for a trade-off between price, reliability and features that you're willing to live with.