Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have this Sharepoint 2010 solution containing 3 projects:

  • Class Library with Model classes
  • Class Library with LINQ to SQL data context
  • Sharepoint 2010 project
    • WCF REST service
    • 3 Visual web parts
    • 1 package
    • 1 feature

I'm developing an installer that will run the PowerShell cmdlets to install the solution.

But I have some code in the feature's FeatureInstalled event that needs to create and initalize a SQL server 2008 database. The connection string to this server will be asked to the end user in the installer.

How can I pass this connection string to the solution in order to make use of it in the FeatureInstalled event?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

Short answer: you can't. And why would you create the database using a feature? If you are creating an installer anyway, create the DB there using a db create script or a custom seetup action.

As for storing the DB connectionstring and or DB credentials: Use the SecureStore Service Application. See this article for information on how to configure the securestore and also the code needed for retrieving the values from it. An alternative is to store the the connection string in the webapp or site collection's PropertyBag.

P.S. Both options can be scripted using PowerShell

share|improve this answer
    
Yes, I guess I'll end up creating the DB in the installer. Thanks. –  emzero Apr 1 '12 at 17:20

You can create custom property for the feature. In your Feature CAML you can define

<Feature id...>
    <Properties>
      <Property Key="ConnectionString" Value="String"/>
    </Properties>
</Feature>

Then use this code in the feature receiver

SPFeatureReceiverProperties.Feature.Properties["ConnectionString"]

In this case the user should modify feature CAML before activation. In this case the user should have access to the server folders...

In other case you can create configuration page, install it to the site, and create custom action for navigation button to this page. In this page you can run code that is locating in feature receiver now.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.