December 29, 2013

SHarePoint get List of Specific (Task, GenericList, DocumentLibrary, Announcements) Object Model C#



 SharePoint saves everything in format of list below are few type of Lists those we use frequently.
  • GenericList
  • DocumentLibrary
  • Survey
  • Announcements
  • Contacts
  • Tasks
Complete List Type template can be found here

Now some time it happens your clients come up with some requirement and you have to get all list of specific Type of SPList. its not big deal ;)

Suppose I have 20 list few are Task type few Announcement Type and few are generic list, Now I wants only those list whose Template Type is Announcement.


C# Code:
using (SPWeb oWeb = SPContext.Current.Site.OpenWeb("\RelaviteUrl",false))
            {
                foreach(SPList oList in oWeb.Lists)
                {
                    if (SPListTemplateType.Announcements == oList.BaseTemplate)
                    {
                        //(oList.Title);
                    }                
                }                
            }



Please share any issue or findings on this. 


--
Regards,
Praveen Pandit

December 22, 2013

Error: Cannot connect to the configuration database. ; getting error while hitting Windows SharePoint websites or Central Administrator



 Error "Cannot connect to the configuration database" when you connect to a Windows SharePoint websites or Central Administrator.





This problem occurs when you made some update on windows / install or uninstall  of MS products. You may have tried IISreset or server reboot but nothing worked. So lets try below point

1)    By looking at massage a school guy can say its unable to connect Sql Database. So first step is to check Sql services and try to start/restart and check.Refer Link for details.
Still that doesn’t work you can try below option
2)    Try to reconfigure Sql
 It may be Your configuration trying to connect to the DB via the wrong port. Ir may be incorrect configuration setting accounts and all. Or may be firewall rule blocking you. To resolve this you can do Configuration of DB by configuration wizard you can refer Link for details.
3)    Again this didn’t worked you it means your services and configuration is correct lets use some commands to do it work refer Link.
4)    Go to Sql management and give permission to account
5)    Or go to SQL server configuration manager change service account and try again by restarting/starting Sql services and again make old account and retry.


Don't forget to run with elevated privileges!


You can share your views, issue or findings below, on this.

--
Regards,
Praveen Pandit

November 20, 2013

SharePoint Site lock, unlock, Web unable to update, delete, add options are invisible, unable to see recycle bin, site is locked, how to make site ready only , unlock site



SharePoint came with so many new features and functionality. it is stable and matured technology.
if user if unable to see edit, delete or Add button even has full control and contribute permission or also unable to see recycle bin. One of the reason of it you Site / Web is locked and no database related update can be made (in short no update). here you may got my point. the site or Content DB is locked we need to unlock it. it happens it your backup or restore is interrupted or some SharePoint job is couldn't completed.

Or some time you are doing some important task, like doing scheduled backup or restore. or anything related to it. so you don't want changes during you process. it simple lock it.

Now how should we lock ant site or unlock. the best and easiest way is PowerShell.


 PS C:\Users\Admin> $site =Get-SPSite -Identity “http://SiteOrWebUrl”  
 PS C:\Users\Admin> $site.MaintenanceMode   
 True  
 PS C:\Users\Admin> $Site.ClearMaintenanceMode  
 PS C:\Users\Admin> Set-SPSite -Identity “http://SiteOrWebUrl” -LockState "Unlock"  


Another way it stsadm command, which is also preferred and easy way.

 C:\Users\Admin> stsadm -o setsitelock -url http://xxx -lock none  


Don't forget to run command prompt with elevated privileges!


Please share yours findings or issue if any on this.

--
Thanks for visiting!!,
Praveen Pandit