3

i created a data access layer dll using subsonic. however it uses the connectionstring from the app.config. i am using it in ninjatrader and dont want to mess around with the ninjatrader app.config for the connecitonstring. how do i avoid this issue.

junkone
  • 1,427
  • 1
  • 20
  • 45

3 Answers3

3

I believe the best you can hope for here is to use a separate file for the connection strings:

in app.config

<connectionStrings ConfigSource="myConnStr.config" />

in myConnStr.config:

<connectionStrings > 
  <add .... />
  <add .... />
</connectionStrings > 
James Curran
  • 101,701
  • 37
  • 181
  • 258
  • is there a way that i can force subsonic to look for connectionstring info in a xml file or programatically hardcode the connectionstring. – junkone Jul 08 '10 at 20:33
3

I believe you can set it at runtime using the SetDefaultConnectionString method:

SubSonic.DataService.GetInstance("InstanceName").SetDefaultConnectionString("ConnectionString");
rtalbot
  • 1,615
  • 10
  • 13
3

Sample how to programatically hardcode connectionstring:

string connectionString = string.Format(@"Data Source={0}", Path.Combine(this.ConfigFolder, ConfigDb));
string providerName = @"System.Data.SQLite";
var provider = ProviderFactory.GetProvider(connectionString, providerName);
_configRepo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations);

This sample use sqlite database which is located in this.ConfigFolder. ConfigDB contains name of a database file.

rupo76
  • 31
  • 4