.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Creating SPContentDatabase programatically using Object Model

Posted By:      Posted Date: October 19, 2010    Points: 0   Category :SharePoint

Hi I m trying to create a content database programatically but getting the error "Object reference not set to an instance of an object."

any help would be highly appriciated....

Thanks in Advance.....

View Complete Post

More Related Resource Links

OneNote 2010: Creating OneNote 2010 Extensions with the OneNote Object Model


Learn how to build applications and plug-ins that interoperate with data from OneNote 2007 and 2010 using the OneNote Object Model library freely available on CodePlex. Andy Gray demonstrates how easy it is to integrate information from OneNote notebooks, sections and pages into smart client and Web apps.

Andy Gray

MSDN Magazine July 2010

Error while creating Termstore using Object Model

Hi, I'm creating term store Group using object model using the below mentioned code:- string TermStore = drManagedMetadataGroups["Term Store"].ToString(); string GroupName = drManagedMetadataGroups["Group Name"].ToString(); string Description = drManagedMetadataGroups["Description"].ToString(); string GroupManagers = drManagedMetadataGroups["Group Managers"].ToString(); string Contributors = drManagedMetadataGroups["Contributors"].ToString(); try { //Type importManagerType = typeof(ImportManager); //Type[] parameterTypes = new Type[1] { typeof(TermStore) }; //ConstructorInfo constInfo = importManagerType.GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, null, CallingConventions.ExplicitThis, parameterTypes, null); //if (constInfo != null) //{ TaxonomySession session = new TaxonomySession(web.Site); TermStore ts = session.TermStores[TermStore]; //ts.AddTermStoreAdministrator(@"test-account-01\d39373g"); //logger.LogToOperations(string.Format("Added managed metadata group administrator '{0}' to '{1}'", GroupName, TermStore), EventLogEntryType.Information); if (!M

Hello Mr. MVP can you please reply to my questions,,,,,,"Creating SPContentDatabase programatically

Hi m trying to Create a SPContentDatabase programatically using Object Model, but getting error of "
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Utilities;
using Microsoft.SharePoint.Deployment;

namespace CreateContentDB
  public partial class Test2 : System.Web.UI.Page
    SPWebApplication webApplication;
    //SPContentDatabaseCollection contentDBs;
    string nameDB = "CNB";
    protected void Page_Load(object sender, EventArgs e)


    protected void Button1_Click(object sender, EventArgs e)
      Uri WebAppUri = new Uri("http://amit:5003");

      SPWebApplication webApplication = SPWebApplication.Lookup(WebAppUri);

      SPContentDatabaseCollection contentDBs = webApplication.ContentDatabases;

      foreach (SPContentDatabase contentDB in contentDBs)

        if (contentDB.Status == SPObjectStatus.Online)
          contentDB.Status = SPObjectStatus.Disabled;
      //SPSite siteCollection = webApplication.Sites.Add();
    private void CreateContentDatabase(string suffix)

Overview of SharePoint Object Model

SharePoint offers a set of structured server-side objects those are widely used to program SharePoint Applications. These objects are hierarchically arranged and you can drill down through the object hierarchy to obtain the object that contains the components of SharePoint Application you need to use in your code.

Scripting: Windows Script Host 5.6 Boasts Windows XP Integration, Security, New Object Model


Windows Script Host (WSH) 5.6, a major upgrade for the WSH environment, provides some significant improvements over previous versions. A brand new security model that is tightly integrated with security in Windows XP allows administrators to place fine-grained restrictions on scripts reducing the risk from malicious code. In addition, local scripts can now run on remote machines, and enhancements to the object model reduce the amount of boilerplate code needed when writing professional code. This overview of WSH 5.6 explains these changes and how .NET and scripting work together.

Dino Esposito

MSDN Magazine May 2002

Whistler: Build More Flexible Console Snap-ins with the MMC 2.0 Object Model


Microsoft Management Console (MMC) 2.0 provides a host of exciting new features for MMC users and snap-in developers. The new MMC 2.0 automation object model allows much of the user interface of MMC 2.0 to be accessed through script, and exposes events so that many tasks can now easily be automated. The new view extension model uses HTML to enable extensions to seamlessly integrate new user interfaces with those of existing snap-ins. MMC 2.0 also includes a specific view extension snap-in, the Extended View snap-in, which provides an interface similar to Web folders. Drag and drop support has been expanded, and console files now use the XML file format. Enhancements to console taskpads make it easier to accomplish tasks.

Vivek Jhaveri

MSDN Magazine March 2001

Client Object Model Resource Center | SharePoint 2010

Are you creating client applications that access SharePoint data remotely? Find overviews, guidelines, and programming tasks for all three flavors of the SharePoint Foundation client object model: .NET managed, Silverlight, and ECMAScript.

Quick Note: Building WPF Applications by Using the SharePoint 2010 Client Object Model

Learn how to create a Windows Presentation Foundation (WPF) application that uses the SharePoint 2010 client object model to retrieve data from a SharePoint Web site.

Using the SharePoint Foundation 2010 Managed Client Object Model with the Open XML SDK 2.0

Write client-side applications that work with Open XML documents that are stored in document libraries by using these two technologies together.

Using the SharePoint Foundation 2010 Managed Client Object Model

Write applications that are based on the .NET Framework and access SharePoint content from clients without installing code on the server that runs SharePoint Foundation 2010.

Video: Overview of the SharePoint 2010 Client Object Model

In SharePoint 2010 there are a number of object models that can be used by developers to access the server. For example, the Client Object Model (Client OM) can be accessed via Web services, via a client (JavaScript) API, and via REST. (Length: 12:22)

Video: SharePoint 2010: Silverlight Client Object Model

In this video you will learn how to use the SharePoint client object model to program a Silverlight application against SharePoint data. (Length: 9:03)

Video: SharePoint 2010: ECMAScript Client Object Model

In this video you will learn how to use the SharePoint client object model to program a ECMAScript application against SharePoint data. (Length: 8:20)

Video: SharePoint 2010 Object Model Hierarchy

This video describes the hierarchy of the most commonly-used objects in SharePoint 2010. (Length: 2:18)

Video: Developing .NET Applications by Using the SharePoint 2010 Client Object Model

This demonstration shows how to use the client object model from a console application. (Length: 8:47)

Video: Developing Silverlight Applications by Using the SharePoint 2010 Client Object Model

This demonstration shows how to use the client object model from a Silverlight application. (Length: 11:15)
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend