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