문제

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?

도움이 되었습니까?

해결책

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

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top