Create a list or document library view programmaticly

When you need to create a view pro grammatically you can use the following code

SPSite oSite = new SPSite("http://{yoursite}");
SPWeb oWeb = oSite.OpenWeb();
SPList oList = oWeb.Lists["Documents"];  
SPViewCollection oViewCollection = oList.Views;
string viewName = "MyView";
System.Collections.Specialized.StringCollection viewFields = new System.Collections.Specialized.StringCollection(); 

string query = "myquery";

oViewCollection.Add(viewName, viewFields, query, 100, true, false);

Access is denied : Crawling SharePoint Content

You might get a access denied error while crawling a SharePoint content source something like below
Access is denied. Verify that either the Default Content Access Account has access to this repository, or add a crawl rule to crawl this repository. If the repository being crawled is a SharePoint repository, verify that the account you are using has “Full Read” permissions on the SharePoint Web Application being crawled. (The item was deleted because it was either not found or the crawler was denied access to it.)
Please follow the following steps to resolve the issue
1.Make sure that the “Default Content Access” account is not an in-built account like local system, network service etc
2. Make sure that the content access account has proper access (read) to the content databases and shared service databases
3.If you are using FQDN for your site add a DisableLoopBackCheck in registry
  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following registry subkey:HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlLsa
  3. Right-click Lsa, point to New, and then click DWORD Value.
  4. Type DisableLoopbackCheck, and then press ENTER.
  5. Right-click DisableLoopbackCheck, and then click Modify.
  6. In the Value data box, type 1, and then click OK.
  7. Exit Registry Editor.
  8. Restart the computer.