Ali Tarhini
Ali Tarhini

Reputation: 5358

connectionstring in linq to sql

the connection string property of the dbml file is currently being read from the application settings file. in the dbml designer code it looks like this :

Global.HMIS.My.MySettings.Default.NewVersionConnectionString

if i try to edit the connection string from the properties window of the dbml file, i cannot change anything there its all read only. also if i try to edit it directly in the code file it changes every time i save. so the hell do i set the connection string property to read from app.config instead of settings.settings file

Upvotes: 1

Views: 430

Answers (2)

Alex F
Alex F

Reputation: 43311

Add your own string to application settings and use it with DataContext(string) constructor, as recommended in the previous post. You can set it initially to connection string generated by LINQ to SQL Wizard, or select any other appropriate default value. Add Connection String editbox to the program Options dialog, allowing to change it to user.

Upvotes: 1

Klaus Byskov Pedersen
Klaus Byskov Pedersen

Reputation: 120937

Your data context class has a constructor that takes a connectionstring. Just read the connectionstring from app.config and use the other constructor.

Upvotes: 1

Related Questions