Pages

Thursday, June 26, 2008

Get Config DB from SPSite

I have got on SharePoint forum how to get the config database from SPSite

using Microsoft.SharePoint;

using Microsoft.SharePoint.Administration;

  using (SPSite site = new SPSite("http://basesmcdev/tester1"))
            {

                SPProcessIdentity pi = site.WebApplication.Farm.TimerService.ProcessIdentity;
                string userName = pi.Username;
                object configDB = pi.GetType().GetProperty("ConfigurationDatabase", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(pi, null);
                SPServer server = (SPServer)configDB.GetType().GetProperty("Server").GetValue(configDB, null);
                string serverName = server.Name;
            }

SharePoint and SQL Server Embedded Edition

After installing SharePoint in my VPC I had found that the SharePoint is using SQL Server 2005 Embedded Edition. But I want SharePoint to use and Named instance of SQL Server Enterprise Edition. So I need to uninstall the Embedded edition and I have found a solution here.

http://jclabaut.free.fr/serendipity/index.php?/archives/27-How-to-Uninstall-Microsoft-SQL-Server-2005-Embedded-Edition-SSEE-Instance.html
and
http://blog.jemm.net/2007/08/06/how-to-uninstall-sql-server-2005-embedded-edition/

In brief the command to uninstall SQL Server Embeddeed Edition use the following command

(on 32-bit platforms)
msiexec /x {CEB5780F-1A70-44A9-850F-DE6C4F6AA8FB} callerid=ocsetup.exe
(on 64-bit platforms)
msiexec /x {BDD79957-5801-4A2D-B09E-852E7FA64D01} callerid=ocsetup.exe

Wednesday, June 25, 2008

Relative Url in MasterPage with SPUrl

Tonight I was working on how to find relative url in Master Page. There was a link in the master page say ImportWizard.aspx. When user is in default.aspx the link was to ImportWizard.aspx. But when user moves to another page say Lists/Tasks/AllItems.aspx then the link is shown as Lists/Tasks/ImportWizard.aspx which is incorrect. So the link is built with current link is added to in front of ImportWizard.aspx. To resolve the problem all I needed was to make the link with respect to current site url rather than current location url. So I thought there may be an built in literal like ~SiteUrl which represents the current site url. But later I have found how to implement it. The way to implement it is


<a href="<% $SPUrl:~Site/ImportWizard.aspx %>" runat="server" >Import Wizard</a>


Here with which I faced problem is I had not added runat="server". If you don't add runat="server" then you'll seee an exception showing a message like "you should use literal control....."

Friday, June 13, 2008

Session State and ReportViewer issue

Yesterday night I was trying to test some ascx control having ReportViewer control in it. By the way I had developed the controls several days ago for one of my  client and it was working then. But in the mean time I have reinstalled SharePoint again and now after deploying the control with SharePoint it was not working Sad. I had surprised of what the issue is......... The same PC, server and SharePoint.

Later I have found that to run RDLC report session state need to be enabled. And this could be done from web.config by uncommenting the following line
<add name="Session" type="System.Web.SessionState.SessionStateModule" />


Also you need to enable session state by setting the property true.
<pages enableSessionState="true"....................


And finally it worked.Open-mouthed

Tuesday, June 3, 2008

Dynamic Links in the Master Page in SharePoint

Few days ago one of my client asked me to have  dynamic links in the quick launch section of the master page. I have been planning how to implement it. Then I have found a workaround. I have developed a web part which will check the current logged-in user's group and depending on the user's group hide/show links.
Finally I have opened the master page in the SharePoint Designer and added the Web part in the Master page. This has solved the problem. I don't know if there's any other way to do.