Saturday 21 September 2013

Migrating Content DataBase from one server to another server in SharePoint 2010


Here are the simple steps to migrate a content database from one SharePoint 2010 server to another SharePoint 2010 server. Basically this task is divided into two parts:
Part-1: Taking Backup of your content DB using SQL Server Management Studio
Part-2: Restoring Backup file of your content DB to another server using SQL Server Management Studio

Part-1: Taking Backup of your content DB using SQL Server Management Studio
[Server 1]
1. Open SQL Server Management Studio as administrator using your credentials. You can see a list of databases available on your server, select the database of which you want to take backup.


2. Right click to your content DB then go to
Tasks > Back Up…

Below screen will appear.

Click OK.

Click Ok again. Backup is done, copy the backup file (.bak) and move it to the server where you to restore.  
Part-2: Restoring Backup file of content DB to new server using SQL Server Management Studio
[Server 2]
1. Open SQL Server Management Studio as administrator using your credentials. Right click Databases, and then go to Restore Database

2. Select the file using “From device” option and click OK.

On successfully completion of restore a pop-up message will appear with the message that “Restore of content database ContentDBName Completed successfully”.
Now your content database is available on another server. And now we are going to replace the newly added content database with old one.
3. Go to
Central Administration > Manage Content Databases
Select the web application

4. Click on content database and check “Remove content database” and click ok. This will remove the existing content database.

5. Click “Add a content database” and enter newly restored content database name.
 And click ok.

Content database is now added to desired web-application.
6. Go to the SharePoint site to see changes.
  
Below are the two screen shots from two different server having same content database.

Server 1 (old ) :


Server 2(new):

Thursday 5 September 2013

Creating Custom HTML Master Page In SharePoint 2013

SharePoint 2013 came up with new trend of creating master pages for SharePoint which is HTML Master Page . Now creating master pages becomes more easy .All you have to do is create your custom HTML markups and with the help of SharePoint 2013 Design Manager ,you can easily convert your normal HTML file to a SharePoint 2013 master page.Here are the steps to create SharePoint 2013 Custom HTML Master page .


1.Prepare your HTML layout ,you can use Dreamweaver or other HTML editor tool.I have create below HTML layout using Visual Studio . 

<html >
<head><title>SPCircle</title><!-- Reference to css --><link rel="Stylesheet" href="/MyStyle/MyMasterStyle.css" /></head><body class="Mybody"><div id="OuterContainer"><div id="MainContainer"><div id="MyHeader"><!-- Header Part --><div id="MyHeaderLeft"><p id="SPC">SPCircle</p></div><div id="MyHeaderRight"><div id="MySearchBox"></div></div></div><div id="MyMenuContainer"><!-- Menu PArt --><div id="MyMenu"></div></div> <div id="ContentContainer" ><!-- Main content of the page will go here --></div><div id="MyFooter"><!-- Footer Part -->
<div id="leftFooter" ></div><div id="rightFooter"></div></div> 
 
</div></
div></body></
html>        As you can see its a pure HTML no other tags are used .Once you completed with your HTML layout ,next step is to put all your files (HTML file, css ,script files, images ) to SharePoint library.

2.Go to

Site Settings >Master page and page layouts > Upload Document

Browse and upload you HTML File to this library,select HTML Master Page from dropdown list .



3.Fill the required description and check  complatible UI for 4 and 15 and press Ok.





4.Publish the uploaded file.



5.Upload your design files (css, javascript ,jQuery files and images) to the path mentioned in you HTML markups or css files .

6.Go to Design Manager


7.Click Edit Master Pages

8.Click on convert an HTML file to SharePoint Master Page


9.Select HTML Master Pages to convert


10.Click ok .Your selected file will gets converted to master page .

 11.Click on the file , you will be redirected to preview page.



So, your HTML is converted to Master Page .Now next job is put SharePoint components like ,top navigation , vertical navigation ,search box to your master page .

12.Click on Snippets Gallery ,a new window will gets opened .Now if u want to add top-navigation  click on the Top-Navigation ,a html snippet will gets generated .Copy the html snippet and paste it on HTML file at appropiate palce.


   For editing and placing HTML snippet, open your html file into SharePoint designer to make this job more easy.Paste the snippet into HTML file and save the file .Refresh the preview page to see changes.Similarly you can add other snippets and snippet gallery.

Note:Move the highlighted(yellow) area to the palce where you want to put main containt of the page.  




13. Once you done , goto master page gallery to approve and publish your newly created master page ,to make it availaible and start using it .

Tuesday 3 September 2013

CAML Query not working in SharePoint 2010

CAML query is really very helpful while working with SharePoint Server Object Model to query data from SharePoint list and libraries.But while working with Server Object Model I was facing one issue ,that my query was not working properly, as i was not getting expected result.I also debug the code and their was no error while debugging in query.Below is the SPQuery which was not working.


SPQuery getSubHeaderQuery = new SPQuery();

getSubHeaderQuery.Query = "<Query><Where> <Eq> <FieldRef Name='MainHeader'/> <ValueType='Lookup'>" + MainHeader + "</Value> </Eq></Where></Query>";




Solution:

After spending some time and struggling with above query , i got soloution and finally my query starts working.Solution is very simple ,just remove the <Query> </Query> tag from the query string  and it will work fine .


SPQuery getSubHeaderQuery = new SPQuery();
getSubHeaderQuery.Query = "<Where> <Eq> <FieldRef Name='MainHeader'/> <Value Type='Lookup'>" + MainHeader + "</Value> </Eq></Where>";