Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top