Create content database dynamically

SPWebApplication mywebApplication;  
Uri myWebAppUrl = new Uri(siteurl);  
myWebApplication = SPWebApplication.Lookup(myWebAppUrl);  
string databaseName = "WSS_Content_" + Guid.NewGuid().ToString();  
myWebApplication.ContentDatabases.Add(databaseservername, databaseName, null, null, 1000, 10000, 0)

Related Post

1 thought on “Create content database dynamically

  1. Hi Dhirendra,

    I have used your code snippet to create content database in a webpart but i was prompted with a access denied error. any pointer or help will really save my days 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.