orelzion
orelzion

Reputation: 2532

LINQ connection string location

I'm using LINQ in visual studio using the DataClasses Where can I change the connection string from the code?

Upvotes: 1

Views: 269

Answers (1)

Brian
Brian

Reputation: 1097

You should be able to add a connection string to your project's App.config or Web.config, then when you instantiate your data context, you should be able to supply the name of the connection string to use. e.g.:

App.config:

<connectionStrings>
  <add name="connectionName" value="..." />
</connectionStrings>

Code using data context

var context = new DataContext( "connectionName" );

Upvotes: 4

Related Questions